I was messing around with my next big game, and I want only TBC and OBC members to be able to play to prevent guests from hacking/ruining others' game experience. Here is my script:
local player = game.Players.LocalPlayer game.Players.PlayerAdded:connect(function(player) if player.MembershipType == "None" or "BuildersClub" then player:Destroy() else print (player.Name..'is a tbc/obc member!') end end)
Thanks for reading!
When comparing Enums, you have to be exact and can't use strings. Also, try using :Kick() instead of :Destroy(), it actually disconnects the player. Make sure this is in a normal script.
Also, you don't need the player variable, there is already one made when the PlayerAdded event fires.
game.Players.PlayerAdded:connect(function(player) if player.MembershipType == Enum.MembershipType.None or player.MembershipType == Enum.MembershipType.BuildersClub then --You can't use strings for comparing Enums. Also, you can't do "player.Membership == "SOMETHING" or "OTHERTHING", you have to repeat the condition. player:Kick() --Better way of kicking the player. else print (player.Name.." is a TBC/OBC member!") end end)
First of all you have 2 things 'player' is, in the function and defining it on the 1st line, using LocalPlayer means this has to be in a local script in the player or their character. Firstly to stop guest coming, make sure it's BC only, then you don't have to worry about NBCs joining. Then put the script below in a script in workspace.
game.Players.PlayerAdded:connect(function(plr) if plr.MembershipType ~= Enum.MembershipType.TurboBuildersClub or plr.MembershipType ~= Enum.MembershipType.OutrageousBuildersClub then -- Check For TBC Or OBC, you can't just use the value's text. plr:remove() -- Remove The Player end end)
Hope this helped, if it did please vote up! :)
EDIT: Whoops, when I posted my answer I didn't see someone else had already posted.