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

Simple question on if then statement?

Asked by
F_lipe 135
10 years ago

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.

0
If I'm not wrong I did think ~= means does not equal. F_lipe 135 — 10y

1 answer

Log in to vote
3
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
10 years ago

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
Lol I used to destroy players, you are giving me so much info xD Legojoker 345 — 10y
Ad

Answer this question