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

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

Asked by 5 years ago

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

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 User#23365 30 — 5y
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 User#23365 30 — 5y

2 answers

Log in to vote
0
Answered by
SpiralRBX 224 Moderation Voter
5 years ago

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

Ad
Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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."

0
but this also isn't the complete answer, the other problem is that it's a Script inside a PlayerGui. Elixcore 1337 — 5y
0
um MouseButton1Click doesn't hold a player parameter so use LocalPlayer and note that you cant kick players from the client User#23365 30 — 5y
0
ok thanks WideSteal321 773 — 5y

Answer this question