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

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

Asked by 4 years ago

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.

0
I messed up sorry. :/ TheKingOfDaMemes 24 — 4y
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) TheKingOfDaMemes 24 — 4y
0
Put wait(0.5) and debounce = false before line 5 Nguyenlegiahung 1091 — 4y
0
Ok can you put that in answers? Thanks! TheKingOfDaMemes 24 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

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

0
Thanks man! TheKingOfDaMemes 24 — 4y
0
np Nguyenlegiahung 1091 — 4y
Ad
Log in to vote
0
Answered by
Nckripted 580 Moderation Voter
4 years ago

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!

Answer this question