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

My Kick GUI isn't kicking players like it is supposed to, Please help if you can :) (?)

Asked by 5 years ago

Hello, I've been programming a simple kick GUI, so when you click 'Kick' it'll get the players name from a text box in the GUI and the reason of the kick, but it doesn't kick me when I test it.

The script is a Local Script not server side.

Here it is:

-- // Script Written by: DevCadenator
-- // Script title: Basic Kick Script, 29/10/2018 (DD/MM/YY)
-- // Notice: None

script.Parent.MouseButton1Click:Connect(function()-- When the player clicks on the button it will run the function below.
    -- Varibles --
    local player = game.Players:FindFirstChild(script.Parent.Parent.KickValue.Text) -- The player to kick.
    local reason = script.Parent.Parent.KickValue2.Text -- The reason that the Admin entered.
    -- Primary Script --
    if player == nil then -- Checks if the player doesn't exist.
        warn("Player - " .. script.Parent.Parent.KickValue.Text " does not exist!") -- Sends a warning to the console that the player doesn't exist.
    else -- If the player exists then the code will continue below, else it will stop.
        if reason == "Reason" then -- Checks if the Admin didn't write a reason.
            print("No reason provided for " .. player.Name .. " kick.") -- Prints to console saying that there is no reason provided for the kick.
        player:Kick("No reason provided") -- Kicks the player with the text saying "No reason provided"
        else -- If the reason isn't blank then it will continue to run the code below.
            print("Checking permission level to kick " .. player.Name .. " for " .. reason) -- Prints to the console that administrator.
            wait(0.1) -- Puts a wait time in-between when a string is printed to console and when the player is kicked.
            player:Kick(reason) -- Kicks the player for the reason.
            print(player.Name .. " has been kicked for: " .. reason) -- Prints to console that a player has been kicked and for what reason.
    -- End of Script --
        end
    end
end) -- This will end the function. 



--- Script created for - The Queens Hotel ---


Any help would be greatly appreciated.

Caden

0
Could you get rid of all those comments LOL greatneil80 2647 — 5y
0
^ comments are helpful wym User#22604 1 — 5y
0
But over-commenting code is a code smell User#19524 175 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

ServerSide

The Kick action is available only through the Server. So to fix this use Remotes

Handle all the GUI on the client side, and then have it fire a remote to signal the server to kick the player. As an example:

LOCAL

script.Parent.MouseButton1Click:Connect(function()
    game.ReplicatedStorage.kickEvent:FireServer(KickValue.Text, KickValue2.Text)
end)

SERVER

game.ReplicatedStorage.kickEvent.OnServerEvent:Connect(function(plr, KickValue, KickValue2)
    game.Players:FindFirstChild(KickValue):Kick(KickValue2)
end)

Keep in mind this is just example code, I can not provide you with an entire script. If you need help with anything, just comment below this.

0
I'm confused where to put things, Starnamics 24 — 5y
0
The Kick method can be done from the client, but clients can only kick themselves. User#19524 175 — 5y
0
Oh. Starnamics 24 — 5y
0
you really don't want to let any player kick anyone through a remote event User#22604 1 — 5y
View all comments (4 more)
0
Oh, It's for an admin pannel lol. Starnamics 24 — 5y
0
I've done what you said, but it still isn't working. Starnamics 24 — 5y
0
I'm not getting any errors in studio though. Starnamics 24 — 5y
0
Just taking a quick look, this could looks like it'd work. Just a warning though. You MUST verify SERVER SIDE that this player should be able to kick other players if you don't want exploiters to kick random people. FrostTaco 90 — 5y
Ad

Answer this question