im making a brick that kicks you but its very laggy with brick and it keeps `printing: 15:42:48.173 - Stack Begin
15:42:48.175 - Script 'Workspace.KickBrick.Script', Line 6
15:42:48.177 - Stack End`
but it does kick you, any help is very admired
1 | script.Parent.Touched:Connect( function (hit) |
2 | local plr = game.Players:GetPlayerFromCharacter(hit.Parent) |
3 | if hit.Parent = = plr then |
4 | plr:Kick( "Congrats on doing the secret, you got to do it again once badge is ready" ..plr.Name.. "DON'T TELL ANYBODY" ) |
5 | else |
6 | plr:Kick( "Error 232 " ..plr.Name.. " Were Truly Sorry." ) |
7 | end |
8 | end ) |
The problem is, without a debounce it will keep firing the .Touched event, thus making it very laggy. To fix it, of course, use a debounce:
01 | local debounce = true |
02 | script.Parent.Touched:Connect( function (hit) |
03 | local plr = game.Players:GetPlayerFromCharacter(hit.Parent) |
04 | if plr then |
05 | if debounce then |
06 | debounce = false |
07 | plr:Kick( "Congrats on doing the secret, you got to do it again once badge is ready" ..plr.Name.. "DON'T TELL ANYBODY" ) |
08 | else |
09 | plr:Kick( "Error 232 " ..plr.Name.. " Were Truly Sorry." ) |
10 | end |
11 | end |
12 | debounce = true |
13 | end ) |
Take away the if hit.Parent == plr line and replace it with
1 | if plr then |
-Ducky
Developer
Youtuber