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

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

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)

7 comments

0

try printing this : game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId,Id)

0

also you never checked is plr existed

0

where do you think i should do the "if plr then"

3

If this were to work, once one player had the gamepass, everyone would be able to enter since cancollide is server wide.

0

Are you sure the gamepass ID is correct?

0

are you testing if it works in studio or in game? sometimes my gamepass scripts are buggy in studio but work in game.

0

@zor_os, it should make no difference whatsoever

1 answer

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)

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