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

Simple question on if then statement?

Okay so this is pretty simple I've never used a command like this I should be able to debug it but it's got me stuck.

This is what I have:

if Player.Name ~= "shockyman101" then
	Player.Name:remove()
end

I'm currently making a game but I want it close to public so when people join I want it to automatically remove them from the game.

If you could help me debug this that would be great.

1 comment

0

If I'm not wrong I did think ~= means does not equal.

1 answer

✓ Accepted answer

Your problem is actually in the second line of code there.

Player.Name is a string, and strings do not have a remove method. As well, the remove method for ROBLOX objects is deprecated.

Try this instead:

if Player.Name ~= "shockyman101" then
    Player:Kick()
end

The Kick method of Player objects will remove the Player being kicked from the Game, while also disconnecting them so that they can't exploit and get back into the game without their Player.

1 comment

1

Lol I used to destroy players, you are giving me so much info xD

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