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

How do you make it so it if a player must have gamepass To Pass?

**local function** onTouched(hit)
	**local** character = hit.Parent
	**if** character **then**
		**local** player = game.Players:GetPlayerFromCharacter(character)
		**if** player **then**
			**if** player:IsInGroup(7) **then**
				-- Only open the door if it's closed.
				if not doorOpen then
					open()
					wait(3)
					close()
				end
			elseif doorOpen then
				character:BreakJoints()
			end
		end
	end
end

Is it possible? I want to make this a vip door. Full code here:

---------iHavoc Studios----------

local door = script.Parent local doorOpen = false

local function open() doorOpen = true door.CanCollide = false -- Make players able to walk through the door. So no touch plz.

for transparency = 0, 1, 0.1 do
	door.Transparency = transparency
	wait(.1)
end

end

local function close() for transparency = 1, 0, -0.1 do door.Transparency = transparency wait(.1) end

doorOpen = false
door.CanCollide = true -- Make players unable to walk through the door.

end

local function onTouched(hit) local character = hit.Parent if character then local player = game.Players:GetPlayerFromCharacter(character) if player then if player:IsInGroup(7) then -- Only open the door if it's closed. if not doorOpen then open() wait(3) close() end elseif doorOpen then -- Intruder! Don't let them get through the door alive. -- Yes, I'm serious, don't mess with this part Andrew! character:BreakJoints() end end end end

door.Touched:Connect(onTouched)

2 comments

0

use UserOwnsGamePassAsync

0

thx

1 answer

local function onTouched(hit)
local character = hit.Parent 
if character then 
local player = game.Players:GetPlayerFromCharacter(character)
if player then 
if player:IsInGroup(7) then -- Only open the door if it's closed.
if not doorOpen then
 open() 
wait(3) 
close() 
end 
elseif doorOpen then -- Intruder! Don't let them get through the door alive. -- Yes, I'm serious, don't mess with this part Andrew! 
character:BreakJoints() 
end 
end 
end 
end

I had to copy paste then separate the code so excuse the no indenting..

You see the part where it says "if player:IsInGroup(7)" if you want it to be a gamepass, replace it with

if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, GamePassId) then

Replace GamePassId with the ID of the gamepass, you can find it here.

1 comment

0

Thanks!

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