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

How do you make a game Tbc only?

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

✓ Accepted answer

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)

3 comments

0

Thanks, it really helped!

0

You're welcome.

0

Whoops, when I posted my answer I didn't see someone else had already posted.

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.

2 comments

0

t's ok. you forgot the d on playeradded.

0

Just a heads up, you have to repeat the condition when using and/or, otherwise the script will throw an error.

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