if having trouble with this script, :C
01 | local isTouched = false |
02 |
03 | local alreadyPro = game.Workspace.Characters.AlreadyPro.HitBox |
04 |
05 | local onCollision = function (collidedPart) |
06 | -- "OI WOTCHIT WILL YA" |
07 |
08 | local partParent = collidedPart.Parent |
09 | -- Look for a humanoid in the parent |
10 | local humanoid = partParent:FindFirstChildWhichIsA( "Humanoid" ) |
11 | print (humanoid) |
12 |
13 | if isTouched = = false and humanoid then |
14 | print ( 'touched already pro' ) |
15 | game:GetService( "Chat" ):Chat(game.Workspace.Characters.AlreadyPro.Head, "OI WOTCHIT WILL YA" , Enum.ChatColor.White) |
Answer: You need a Debounce.
01 | local isTouched = false |
02 |
03 | local alreadyPro = game.Workspace.Characters.AlreadyPro.HitBox |
04 |
05 | local debounce = true -- initialize debounce |
06 | local onCollision = function (collidedPart) |
07 | -- "OI WOTCHIT WILL YA" |
08 |
09 | local partParent = collidedPart.Parent |
10 | -- Look for a humanoid in the parent |
11 | local humanoid = partParent:FindFirstChildWhichIsA( "Humanoid" ) |
12 | print (humanoid) |
13 |
14 | if debounce and isTouched = = false and humanoid then |
15 | debounce = false -- lock debounce |
Note: You can unlock the debounce whenever you would like. Usually people will wait for something to finish and then allow the debounce to be unlocked. This is done like so:
debounce = true
.