Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local part = script.Parent --Script's Parent
- local debounce = false --Boolean
- function run(hitPart) --Function that runs when the part is touched
- --Hitpart is the part that touched the part
- local humanoid = hitPart.Parent:FindFirstChild("Humanoid")
- --The humanoid is the character's humanoid that has health/other humanoid properties
- if not debounce and humanoid then --We check if debounce is false and if there is a humanoid, if there is we run the function
- debounce = true --Set debounce to true
- humanoid:TakeDamage(15) --The humanoid takes damage
- wait(2) --We wait 2 seconds
- debounce = false --Set debounce to false
- elseif debounce == true then --If debounce is true then print the debounce's value (true)
- print(debounce)
- end
- end
- local connection = part.Touched:Connect(run) --Connects the part.Touched event to our run function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement