#How would I make a kick button within a screengui?

1 messages · Page 1 of 1 (latest)

hexed jacinth
#

I'm trying to essentially make an admin panel, but I can't understand on how to make the kick/ban feature. Does it require remote events or can it simply be ran through StarterGui? (I'm also trying to try to keep this all in startergui as I'm pretty dumb in removeevents, so is it possible?) (sorry if this is a dumb question)

green otter
#

Do you know how to do that or would you like help?

hexed jacinth
green otter
hexed jacinth
#

why are you typing so long

#

its been 20 minutes.

#

im scared.

green otter
#

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)
hexed jacinth
green otter
#

Might have been a bit too much detail

hexed jacinth
#

oh my goodness.

green otter
#

I ran out of message space

hexed jacinth
#

thats insane.

#

thank you!

green otter
#

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)
hearty mountain
#

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.

hexed jacinth
#

its just for a practice admin gui