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