Hello, I am trying to make made an admin panel GUI that I can use in my games, and I can’t seem to get it working right. To see what player it needs to kick, it needs to look at what the player puts in a text box. This means that it needs to be a local script. But, if it’s a local script then it only would happen for the player trying to kick someone. I have tried changing it to a server script, which didn’t work. The only other thing I can think of that might work is it telling another script what the text the player put in the text box, and then running a server script that would kick them. But, I don’t know how to do this. I am new to scripting and I am still learning, so I’m sorry if the solution is very obvious.
Here is the script, which is local in a button, that I have tried.
Remote Events are your friend!
The linked wiki article has some excellent instructions on how to use them, and I advise reading those instructions regardless. But for an example on how to use them with your intended use:
Basically, you put the “RemoteEvent” object anywhere you want.
On the client localscript script, perform something along the lines of RemoteEvent:FireServer(TextBox.Text) …when the button is clicked. This sends the information to the server, and any serverscript connected to this RemoteEvent will have the event fire with the given information (as well as the player who fired the event).
In a different script for the server, you kick the player from here using code something like: RemoteEvent.OnServerEvent:Connect(function(callingPlayer, playerToKick) game.Players[playerToKick]:Kick() end)
It’s always good to practice secure scripting measures. While normally only your scripts can call these function/events only when you want them to, exploiters in your game can ignore these limitations and call RemoteEvents and RemoteFunctions whenever and however they want.
So in order to exploiter-proof this part of your game, you’d want to check that whoever is sending the event (the callingPlayer in my example) is an admin, so you can’t have exploiters firing the event for the server to kick whoever they want.