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 3 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

script.Parent.Touched:Connect(function(hit)
    local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
    if hit.Parent == plr then
        plr:Kick("Congrats on doing the secret, you got to do it again once badge is ready"..plr.Name.."DON'T TELL ANYBODY")
    else
        plr:Kick("Error 232  "..plr.Name.."  Were Truly Sorry.")
    end
end)
0
try putting a 1 second delay or .5 3F1VE 257 — 3y
0
that also worked BrishedBoomer 29 — 3y

2 answers

Log in to vote
0
Answered by 3 years ago
Edited 3 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:

local debounce = true
script.Parent.Touched:Connect(function(hit)
    local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
    if plr then
    if debounce then
    debounce = false
        plr:Kick("Congrats on doing the secret, you got to do it again once badge is ready"..plr.Name.."DON'T TELL ANYBODY")
    else
        plr:Kick("Error 232  "..plr.Name.."  Were Truly Sorry.")
    end
    end
    debounce = true
end)
Ad
Log in to vote
0
Answered by 3 years ago

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

if plr then

-Ducky

Developer

Youtuber

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

Answer this question