#How would I make a kick button within a screengui?
1 messages · Page 1 of 1 (latest)
Yes, it needs to be done server-side with a remote event.
Do you know how to do that or would you like help?
shucks
would prefer some help as I'm VERY new to scripting and i'm just trying things out.
Do you know how RemoteEvents work?
Well I've got the gist of it

why are you typing so long
its been 20 minutes.
im scared.

RemoteEvents send messages from the client to the server.
The Client is the game running on the Player's device, any code here (from LocalScripts) will only affect that player. For example, if you created a Part with a LocalScript then only that player would see the part.
The Server is running on Roblox's servers. Anything on the Server is copied to all of the Clients. So, if you created a part on the server (with a Script), every single player would see it.
The Player:Kick() method can be run on the Client, but only for the LocalPlayer (the player on that device). If you want your admin panel to be able to kick any player, it needs to be server-side.
But how would I make it server-side?
Have a RemoteEvent (preferably in ReplicatedStorage), I'm going to name mine 'KickEvent'. When the Client clicks a certian button on your ScreenGui (a TextButton or ImageButton), fire the Kick RemoteEvent.
LocalScript in StarterGui->ScreenGui->TextButton/ImageButton
local Event = game.ReplicatedStorage.KickEvent
local Button = script.Parent
Button.MouseButton1Click:Connect(function()
-- Run this code when the button is clicked
Event:FireServer()
end)
On the server, listen for when the RemoteEvent is fired. Once it is, kick the given player.
Script in ServerScriptService
local Event = game.ReplicatedStorage.KickEvent
Event.OnServerEvent:Connect(function(Player)
Player:Kick() -- Kick the player who fired the event
end)
You probably don't want your admin panel to kick the admin though, so add in a field for which player should be kicked:
LocalScript:
Button.MouseButton1Click:Connect(function()
Event:FireServer("Username") --send the username of a certian player
end)
Script:
Event.OnServerEvent:Connect(function(Player, Username) --Also take a Username now
local TargetPlayer = game.Players[Username] --Find the player we want to kick
if TargetPlayer then
TargetPlayer:Kick()
end
end)
oh.
Might have been a bit too much detail
oh my goodness.
I ran out of message space
You could also use a TextBox (a box that you can type text into 🤯) to take in a Username, instead of a button
local TextBox = script.Parent.TextBox
TextBox.FocusLost:Connect(function(enterPressed)
if enterPressed then
-- This code will be run when you type something into the textbox and hit enter
Event:FireServer(TextBox.Text) -- Will be the text written in the TextBox
end
end)
DUDE THIS IS HORRIBLE
A hacker can easily fire the event illegitimately and kick all your players
You need to add an if statement insuring that the player is an admin. There’s many ways to verify whether or not they’re an admin, probably the best way to do is it to check their group rank.
ITS ENOUGH
its just for a practice admin gui