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

How to add an custom kick reason?

Asked by 4 years ago

Hey! I was wondering how to make a custom reason like: /kick roblox reason

code

function commandTable.kick(message, victim, reason)
    victim = findPlayer(message)
    if victim and victim.Character then
        victim:Kick("[Kick]: You have been kicked from the game! Reason: "..reason..".")

    end
end

that doesnt work Any fix?

0
What do you mean by, "that doesn't work", is there an error in the console, is the reason worded wrong? Tweakified 117 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

Why are you passing a victim argument, then immediately assigning it to the value of findPlayer(message)? In the limited code you posted, reason is just whatever is being passed into the function, so if you did this:

function commandTable.kick(message, victim, reason)
    victim = findPlayer(message)
    if victim and victim.Character then
        victim:Kick("[Kick]: You have been kicked from the game! Reason: "..reason..".")

    end
end

--and then you call this function from somewhere

commandTable.kick(message,victim,reason)

"message" is likely a string, victim is most likely a Player object; reason can be many things, but it mostly makes sense if it's a string as well; whatever you pass through to the function will be the reason. If you want the player to give his own custom reason, example: /kick noobplayer123 trolling You would have to use string manipulation to find the reason, but if you're already finding the commands from the .Chatted event, it shouldn't be much more difficult.

Ad

Answer this question