Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why isn't this script working?

Asked by 8 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

For some reason, the touched event part doesn't seem to be working. Please Help!

tool.Activated:connect(function()
if debounce == true then
debounce = false
local firesound = tool.Sound
firesound:Play()
wait(.3)
firesound:Stop()
local pos = tool.Handle;
local endPos = m.Hit.p;                 
local shot = Instance.new("Part", workspace)    
shot.Name = "Shot_" .. player.Name;
shot.CanCollide = false;
shot.Shape = "Ball";
shot.Size = Vector3.new(1, 1, 1);       
local ray = Ray.new(pos.CFrame.p, (endPos - pos.CFrame.p).unit * 300); -- CHANGE 300 HERE TO A SMALLER NUM IF YOU WANT A SHORTER RAY        
local hit, position = workspace:FindPartOnRay(ray, player.Character);
local distance = (position - pos.CFrame.p).magnitude;       
shot.CFrame = CFrame.new(position, pos.CFrame .p) * CFrame.new(0, 0, 1.5) * CFrame.new(0, 0, -distance);        
game.Debris:AddItem(shot, 1);       
local sT = 0;           
local bv = Instance.new("BodyVelocity", shot);      
bv.velocity = -shot.CFrame.lookVector * speed;
wait(.4)
debounce = true
shot.Touched:connect(function(hit)
    if hit.Parent.Torso:FindFirstChild("Fire") then
        local fire = hit.Parent.Torso.Fire
        game:GetService("Debris"):AddItem(fire, .01)
    end
end)
end
end)
1
Is there an object called Fire as a descendant of hit.Parent.Torso? BlackJPI 2658 — 8y
0
yes. swimmaster07 25 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

You need to put the Touched function code fragment into each shot. You would do this by cloning a pre made script and puting that script clone as a parent of the shot you just made.

Good luck!

0
umm im not exactly following u. Help! swimmaster07 25 — 8y
Ad

Answer this question