Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

KickBrick is very very laggy?

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)

2 comments

0

try putting a 1 second delay or .5

0

that also worked

2 answers

✓ Accepted answer

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)

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

if plr then

-Ducky

Developer

Youtuber

1 comment

0

hmm it doesn't seem to work

This discussion is preserved as it was. New answers, comments, and votes are closed.