Monday, January 14, 2013

Game Passes - Getting Them To Work

Hello. If you make games, one important aspect for your game are Game Passes.

There are many ways to use Game Passes, and the most used way is allowing people to enter a VIP room. But how does one make a Game Pass VIP door? Well, today, I am going to show you how! Let's get started!



Building The Door*


Building the door should not be a problem, but I am still going to describe it. You will need to use ROBLOX Studio. First, you will need to create the door. Usually, you will want it to be of the size of a character, so players can get through. You will probably want the door to be anchored too, unless you expect it to move whenever a player touches it...
The size of a player's character is 4 x 5 x 1, so you will probably want your door to have that size. However, you can't get exactly that size with the Brick FormFactor. Therefore, you will probably want to change the FormFactor to Symmetric, so you can get the exact size. Another solution would be to simply make the door slightly bigger than the exact size of a character.

Making The Door Work

You should now have a door built. To make the door only allow people who have the Game Pass to enter, you need to insert a Script into the door. To insert a script, click Insert>Object>Script.

Once you insert it, open it. If you are using ROBLOX Studio 2.0, it will open when you insert the script. Copy the following code and paste it into the script.



local door = script.Parent
local passID = 1337 -- Change that to the passes ID

function pass(p, id)
return game:GetService("GamePassService"):PlayerHasPass(p, id)
end

script.Parent.Touched:connect(function(p)
if p then -- make sure the touching object is still there
plr = game.Players:GetPlayerFromCharacter(p.Parent)
if plr then -- if the toucher is a player, this will return the player
if pass(plr, passID) then
script.Parent.CanCollide = false
wait(1)
script.Parent.CanCollide = true
else
p.Parent:BreakJoints()
end
end
end
end
)

And you're done! Simply place the door where the VIP room is, and add stuff to the room!

I hope you enjoyed this tutorial by PlusJon!

3 comments: