Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why isn't this script working?

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)

2 comments

1

Is there an object called Fire as a descendant of hit.Parent.Torso?

0

yes.

1 answer

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!

1 comment

0

umm im not exactly following u. Help!

This discussion is preserved as it was. New answers, comments, and votes are closed.