I don't know why this isn't working, but I have no errors, and it doesn't work.
Script:
game.Players.PlayerAdded:connect(function(plr)
if plr.Name == "Player" then
plr:Destroy()
end
end)
I don't know why this isn't working, but I have no errors, and it doesn't work.
Script:
game.Players.PlayerAdded:connect(function(plr)
if plr.Name == "Player" then
plr:Destroy()
end
end)
This is probably because your player's name ISNT going to be 'Player'.
Another potential script breaker could be the lack of a yeild before you check the plr's name.
Lastly, rather than destroying the player instance there is a method for kicking players, called 'Kick'
local bannedName = "Player" --change this
game.Players.PlayerAdded:connect(function(plr)
wait(.5)
if plr.Name == bannedName then
plr:Kick()
end
end)
Additionally, you should use a table to define banned players. Then iterate through the table and kick the player if the names match.
local bannedNames = {"Player","Goulstem","Noob","PersonYouHate"}
game.Players.PlayerAdded:connect(function(plr)
wait(.5)
for i,v in pairs(bannedNames) do
if v == plr.Name then
plr:Kick()
end
end
end)
Note: This should be used from a server script
And a last thoughts..
Try banning from player's userId for cases where if the player were to change their name, the ban list would still be accurate.
Try banning from DataStores for auto-updating ban lists.
game.Players.PlayerAdded:connect(function(plr) --When player joins.
if plr.Name == "Player" then --If their name is player
plr:Kick() --Kick player
end -- Ends.
end)
This is a server-side script. Use the kick method instead. Kick Method.
This discussion is preserved as it was. New answers, comments, and votes are closed.