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

Laser doesn't kill if player is jumping on it?

Hi, I'm a really really bad scripter and I only know basic and easy stuff. When I try to test my game I jump on the laser consistently, it wouldn't kill. This is my script: `~~~~~~~~~~~~~~~~~ debounce = false script.Parent.Touched:Connect(function(hit) if not debounce then

debounce = true
	
	if hit.Parent:FindFirstChild("Humanoid") then
		hit.Parent:FindFirstChild("Humanoid"):TakeDamage(20)
	end

wait(0.5)

debounce = false
end

end)

`
Does it have to be published for it to kill instantly?

I don't really know how to tab the script because i'm fairly new to this site so please don't blame me. Sorry.

4 comments

0

I messed up sorry. :/

0

debounce = false script.Parent.Touched:Connect(function(hit) if not debounce then debounce = true if hit.Parent:FindFirstChild("Humanoid") then hit.Parent:FindFirstChild("Humanoid"):TakeDamage(20) end wait(0.5) debounce = false end end)

0

Put wait(0.5) and debounce = false before line 5

0

Ok can you put that in answers? Thanks!

2 answers

✓ Accepted answer

Put wait(0.5) and debounce = false before line 5 The problem is the script isn't running it

2 comments

0

Thanks man!

0

np

This is a better script for a laser, because you don't need to use debounce:

script.Parent.Touched:Connect(function(hit)
	local humanoid = hit.Parent:FindFirstChild("Humanoid") --Checks if there is a Humanoid

	if humanoid then --If there is a humanoid, do following
		humanoid.Health = 0 --Kill player
	end
end)

Hope this helped!

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