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

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

Asked by
iHavoc101 127
5 years ago
01**local function** onTouched(hit)
02    **local** character = hit.Parent
03    **if** character **then**
04        **local** player = game.Players:GetPlayerFromCharacter(character)
05        **if** player **then**
06            **if** player:IsInGroup(7) **then**
07                -- Only open the door if it's closed.
08                if not doorOpen then
09                    open()
10                    wait(3)
11                    close()
12                end
13            elseif doorOpen then
14                character:BreakJoints()
15            end
16        end
17    end
18end

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.

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

end

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

1doorOpen = false
2door.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)

0
use UserOwnsGamePassAsync qChaos 86 — 5y
0
thx iHavoc101 127 — 5y

1 answer

Log in to vote
0
Answered by
Elixcore 1337 Moderation Voter
5 years ago
Edited 5 years ago
01local function onTouched(hit)
02local character = hit.Parent
03if character then
04local player = game.Players:GetPlayerFromCharacter(character)
05if player then
06if player:IsInGroup(7) then -- Only open the door if it's closed.
07if not doorOpen then
08 open()
09wait(3)
10close()
11end
12elseif doorOpen then -- Intruder! Don't let them get through the door alive. -- Yes, I'm serious, don't mess with this part Andrew!
13character:BreakJoints()
14end
15end
16end
17end

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

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

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

0
Thanks! iHavoc101 127 — 5y
Ad

Answer this question