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

KickBrick is very very laggy?

Asked by 4 years ago

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

1script.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
8end)
0
try putting a 1 second delay or .5 3F1VE 257 — 4y
0
that also worked BrishedBoomer 29 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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:

01local debounce = true
02script.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
13end)
Ad
Log in to vote
0
Answered by 4 years ago

Take away the if hit.Parent == plr line and replace it with

1if plr then

-Ducky

Developer

Youtuber

0
hmm it doesn't seem to work BrishedBoomer 29 — 4y

Answer this question