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

How do you make a game Tbc only?

Asked by 9 years ago

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!

2 answers

Log in to vote
0
Answered by 9 years ago

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)
0
Thanks, it really helped! TroytheDestroyer 75 — 9y
0
You're welcome. Spongocardo 1991 — 9y
0
Whoops, when I posted my answer I didn't see someone else had already posted. General_Scripter 425 — 9y
Ad
Log in to vote
2
Answered by 9 years ago

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.

0
t's ok. you forgot the d on playeradded. TroytheDestroyer 75 — 9y
0
Just a heads up, you have to repeat the condition when using and/or, otherwise the script will throw an error. Spongocardo 1991 — 9y

Answer this question