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

[SOLVED] Problem kicking a player and using remote events. am I using the wrong syntax?

so I have this remote event set up that will allow set people to ban a player by typing their name into a text box. I have this tested and it will kick players but when I try to add the reason it will pop up as "Instance". Why does this happen? I have the value (reason for the kick) set as string.

Again everything is setup and working, it bans players

the script part that bans players is"

local function onKickPlayerEvent(player, string)
	player:Kick(string)
end

the localscript past looks like this:

local PlayerToKick = game.Players:FindFirstChild(KickInput)
if PlayerToKick then
	KickPlayer:FireServer(PlayerToKick, "You have been kicked by dev")
end

I will be grateful if someone explains this to me :)

3 comments

0

It’s because you’re currently banning the person who fires the remote. OnServerEvent has a default parameter, the player who called the event. You do not need to specify this in FireServer. Thus, onKickPlayerEvent actually has  three arguments, the player who fired the remote, then the player to ban, then the reason. Currently, you’re kicking the player in the first argument.

1

The first argument in FireServer becomes the second argument in OnServerEvent. This makes the player to ban as the reason. Since the player is an instance, the reason becomes an instance. So to fix this you should make it onKickPlayerEvent(player, playertoBan, reason); playertoBan:Kick(reason).

0

I put the scripts in a code block.

1 answer

Rheines commented the answer, I was using the parameters of the event wrong. Thank you for your help Rheines

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