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

Can someone please help? My vip door wont work! I have tried lots of times!

Asked by 5 years ago

So, my Vip door is a gamepass, and I have done soooooo much but it wont work! I dont know whats going on, but im not getting any errors either. Please help me!

local Id =  5266510
script.Parent.Touched:Connect(function(hit)
--hit
  if hit.Parent:FindFirstChild("Humanoid") then  --makes sure the object touching the door is a player
     local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
     if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId,Id) then
        script.Parent.CanCollide = false
     end
  end
end)

0
try printing this : game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId,Id) theking48989987 2147 — 5y
0
also you never checked is plr existed theking48989987 2147 — 5y
0
where do you think i should do the "if plr then" Jack_mud -5 — 5y
3
If this were to work, once one player had the gamepass, everyone would be able to enter since cancollide is server wide. Crazycat4360 115 — 5y
View all comments (3 more)
0
Are you sure the gamepass ID is correct? Leamir 3138 — 5y
0
are you testing if it works in studio or in game? sometimes my gamepass scripts are buggy in studio but work in game. zor_os 70 — 5y
0
@zor_os, it should make no difference whatsoever User#22604 1 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

So, I will presume you made a game pass after the new game pass update. You can read more about the game pass changes here

Basically this means you can no longer use MarketplaceService to check if someone owns a game pass. NOTE: This only counts for people who made game passes AFTER the new update. Old game passes must use the MarketplaceService:UserOwnsGamePassAsync(userId, gamepassId)

To check if someone owns a game pass, you have to use GamePassService:PlayerHasPass(Player, PassId)

To solve your problem:

local Players = game:GetService("Players");
local GamePassService = game:GetService("GamePassService");
local door = workspace.Door;
local passId = 123

door.Touched:Connect(function(hit)
    if hit and hit.Parent:FindFirstChildOfClass("Humanoid") then
        local player = Players:GetPlayerFromCharacter(hit.Parent);
        if player then
            local ownsPass = GamePassService:PlayerHasPass(player, passId)
            door.CanCollide = false
        end
    end
end)
Ad

Answer this question