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

Why doesn't my kick gui work? (It wont kick the player)

Here's some code.

local player = script.Parent.Parent.Player
local reason = script.Parent.Parent.Reason

script.Parent.MouseButton1Click:Connect(function()
	local player = game.Players
	local kick = player:FindFirstChild(player.Text)
	kick:Kick(reason.Text)
end)

It wont kick the player!!

2 comments

0

its because you cant kick the player from the client (aka from a LocalScript) for security reasons, since exploiters can take advantage of this (kicking a player or the entire server out). so use a RemoteEvent to make the server do it

0

also I wouldn't recommend making a kick gui, as exploiters can take advantage of the communication and the arguments and kick everyone out of the server or a player. instead you could make a chat command since you probably wouldn't need any communication between the server and client

2 answers

✓ Accepted answer

This is my personal kick script for an Admin GUI i made a while back.

function kick()

if script.Parent.Parent.Kick.Text == "" then
else
usertokick = script.Parent.Parent.WhoToKick.Text

ready = game.Players:FindFirstChild(usertokick):Kick('You have been kicked from this game:'.. script.Parent.Parent.Reason.Text)
print (usertokick .. " has been kicked")
wait(2)
end

end

script.Parent.MouseButton1Click:connect(kick)

edit it to your liking if you wish.

Also it is a script, not LocalScript

Please read the whole thing.

all times I say lines is in your script

at line 7 it's player:Kick() and you cant say local player = twice it makes it invalid

Belows script does not work:

local player = game.Players.LocalPlayer
local reason = script.Parent.Parent.Reason

script.Parent.MouseButton1Click:Connect(function()
    player:Kick(reason.Text)
end)

see this for more help.

also what Elixcore said: "The other problem is that it's a Script inside a PlayerGui."

3 comments

0

but this also isn't the complete answer, the other problem is that it's a Script inside a PlayerGui.

0

um MouseButton1Click doesn't hold a player parameter so use LocalPlayer and note that you cant kick players from the client

0

ok thanks

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