I’m a pretty young developer, being only 13. Also, I’m new to Roblox DevForums, so please bare with me if I’m doing something wrong, thanks.
I have been recently working on a custom GUI that allows developers in my group kick and ban players. While making this system, I learned about Remote Events, and how they can allow clients and the server communicate together, which is exactly what I needed to get the system I was making to work. I visited the Roblox Developer Hub and read every little bit about Remote Events, and I did this about 3 times. Despite reading it, I wasn’t able to fix my issue. And here is where that issue comes in.
After putting together the GUI, and making both the server side, and client side scripts, I tested my system. I Inputted the players name, (Player2, as I was playing in test mode) and the Reason they were goign to be kicked kicked. After clicking the ‘Enter’ button I made, instead of the player I entered being kicked, it was PLAYER1 who was kicked, and the reason for being kicked was simply ‘Instance’. Here are my scripts that I used for this system. (Sorry for the sloppy scripting, I like to get them working before making them look better, as it allows me to understand it easier at times.)
Client side script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("KickPlayer")
script.Parent.EnterButton.MouseButton1Click:Connect(function()
remoteEvent:FireServer(game.Players:FindFirstChild(script.Parent.WhoToKick.Text), script.Parent.Reason.Text)
end)
Server side script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("KickPlayer")
local function onButtonClick(PlayerToKick, Reason)
print(PlayerToKick) -- This was used for testing, and the value showed up as 'Player1' (???)
print(Reason) -- This was used for testing, and the value showed up as 'Player2' (???)
PlayerToKick:Kick(Reason)
end
remoteEvent.OnServerEvent:Connect(onButtonClick)
The solution to my issue is probably obvious. Any form of help would be appriciated. If you have any questions about my issue, feel free to ask and I will help you out. Thanks!