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

My ban admin tool won't work it's suppose to loopkick when touched help?

local KickMessage = 'Kicked by an admin.'

script.Parent.Handle.Touched:connect(function(hit)
if hit.Parent:FindFirstChild('Humanoid') then
local Player = game:GetService('Players'):GetPlayerFromCharacter(hit.Parent)
while true do wait()
Player:Kick()
          end
     end
end)

Is there anyway to make this work? It's suppose to loop kick the player when hit by the tool.

2 comments

0

It will error out since when the player is kicked since the player is no longer there. Just store the name of the player and add an if to check if they're there before you kick.

0

Oh no no no, don't store the name of the player, they can change it. Store their ID.

1 answer

✓ Accepted answer

You gotta use a thread every time you ban someone so like this:

local KickMessage = 'Kicked by an admin.'

script.Parent.Handle.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild('Humanoid') then
	local Player = 	game:GetService('Players'):GetPlayerFromCharacter(hit.Parent)
	spawn(function()
		while true do wait()
			if game.Players:FindFirstChild(player) then
				Player:Kick(KickMessage)
		    end
		end
	end)
end
end)

So as you see, spawn(function() is a separate thread that lets the while true do run for ever without yielding the script.

If this doesn't work, tell me in the comments, enjoy and if it worked, accept this answer :D

Also, you might ban yourself if you do this so, rip.

2 comments

0

Awesome! I'll try out if i do ban myself i'll find a way to make it for only some people dont get banned

0

ok

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