Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
BRAEGON -8
5 years ago
Edited 5 years ago

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 :)

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. Rheines 661 — 5y
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). Rheines 661 — 5y
0
I put the scripts in a code block. TheeDeathCaster 2368 — 5y

1 answer

Log in to vote
0
Answered by
BRAEGON -8
5 years ago

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

Ad

Answer this question