Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

My script kicks a player, but does not display the kick message. What is going on?

So, I created an admin GUI. There is a section of that admin GUI that allows an admin to kick players. I put a textbox there so that the admin can type in the kick message. My script does kick the player intended, but it does not show the kick message that the admin put in the textbox.

Here are the scripts:

Client:

kick = script.Parent.Parent.Players.Events.Kick
askServer = game.ReplicatedStorage.AskServer
local plr

kick.Event:Connect(function(player)
	plr = player
end)

script.Parent.Kick.MouseButton1Click:Connect(function()
	askServer:FireServer(plr, script.Parent.Message.Text)
end)

Server:

askServer = game.ReplicatedStorage.AskServer

askServer.OnServerEvent:Connect(function(playerToKick, kickMessage)
	print(kickMessage)
	playerToKick:Kick(kickMessage)
end)

2 comments

0

torchmaster101, does it print something in the chat at least? If not then it might have something to do with what deals the textbox i think

0

It does, but it only prints my username. It doesn't print the kick message.

1 answer

✓ Accepted answer

it is because the server event has 3 parameters that u put into the event and you only defined two of them, the first is always the player in the event (which u didn't define), the playerToKick and then the kickMessage, so the server thinks that the PlayerToKick is the localPlayer and the kickmessage is the playertokick, so the server script should be like this, don't change the localscript

local askServer = game.ReplicatedStorage.AskServer

askServer.OnServerEvent:Connect(function(localPlayer,playerToKick,kickMessage) -- This is where you messed up
	print(kickMessage)
	playerToKick:Kick(kickMessage)
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.