I got it from a model but i want to make it set something on fire when it hit something..Here's the script
debris = game:GetService("Debris")
bolt = script.Parent
damage = 50
debris:AddItem(bolt, 5)
function stick(hit)
-- joint myself to the thing i hit
local weld = Instance.new("Weld")
weld.Part0 = bolt
weld.Part1 = hit
local HitPos = bolt.Position + (bolt.Velocity.unit * 3) -- + (arrow.CFrame.lookVector * 1)
local CJ = CFrame.new(HitPos)
local C0 = bolt.CFrame:inverse() *CJ
local C1 = hit.CFrame:inverse() * CJ
weld.C0 = C0
weld.C1 = C1
weld.Parent = bolt
end
function onTouched(hit)
bolt.BodyGyro:remove()
bolt.BodyForce:remove()
stick(hit)
bolt.HitSound:Play()
local humanoid = hit.Parent:findFirstChild("Humanoid")
if humanoid ~= nil then
tagHumanoid(humanoid)
humanoid.Health = humanoid.Health - damage
wait(1)
script.Parent.Parent = nil
end
local humanoid = hit.Parent.Parent:findFirstChild("Humanoid")
if humanoid ~= nil then
tagHumanoid(humanoid)
humanoid.Health = humanoid.Health - damage
wait(1)
script.Parent.Parent = nil
end
connection:disconnect()
end
function tagHumanoid(humanoid)
-- todo: make tag expire
local tag = bolt:findFirstChild("creator")
if tag ~= nil then
local new_tag = tag:clone()
new_tag.Parent = humanoid
debris:AddItem(new_tag,1)
end
end
connection = bolt.Touched:connect(onTouched)
for i=1,100 do
wait(.1 * i)
if (bolt:FindFirstChild("BodyGyro") ~= nil) then
bolt.BodyGyro.cframe = CFrame.new(Vector3.new(0,0,0), -bolt.Velocity.unit)
end
end
I know it's something to do with, OnTouch and Create Instance New "Fire" |