Hello, I was wondering if any of you guys could help me turn this into a server script?
thanks for helping!
local Players = game.Players
local PlayerToKick = Players.LocalPlayer.PlayerGui.AdminPannel.AdminPannelFrame.PlayerToKick.Text
local KickPlayer = Players:FindFirstChild(PlayerToKick)
local Reason = Players.LocalPlayer.PlayerGui.AdminPannel.AdminPannelFrame.Reason.Text
KickPlayer:Kick(Reason)
end)
local Players = game.Players
local PlayerToKick = Players.LocalPlayer.PlayerGui.AdminPannel.AdminPannelFrame.PlayerToKick.Text
local KickPlayer = Players:FindFirstChild(PlayerToKick)
local Reason = Players.LocalPlayer.PlayerGui.AdminPannel.AdminPannelFrame.Reason.Text
local ServerEvent = game:GetService("ReplicatedStorage"):FindFirstChild("ServerEvent") -- or whatever the ServerEvent is named
ServerEvent:FireServer(KickPlayer, Reason)
Server script:
local ServerEvent = game:GetService("ReplicatedStorage"):FindFirstChild("ServerEvent")
ServerEvent.OnServerEvent:Connect(function(player, KickPlayer, Reason)
KickPlayer:Kick(Reason)
end)
@Afraid4Life’s script is perfect but is just missing one thing. When you get information from a RemoteEvent you should have some way to check that the player firing the RemoteEvent should be able to be kicking players.
To do this you should add a table of admins UserIds to your server script and make sure the player firing the remote event to the server is on that list. Leaving this part out makes it possible for expoiters to kick anyone who they would like.