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

How to add an custom kick reason?

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?

1 comment

0

What do you mean by, "that doesn't work", is there an error in the console, is the reason worded wrong?

1 answer

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.

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