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

VIP Section Access acts as if I don't have VIP?

I'm trying to make a VIP lounge and there would be a door with a teleport, and if you don't have VIP you get teleported to a part which is a few studs away from the VIP door. Since I created the Game Pass myself, I own it. But whenever I touch the door I get teleported back even if I have the gamepass. Anyone know what happens with the script?ack even if I have the gamepass. Anyone know what happens with the script?

local teleport = game.Workspace.SpecialPart1
mps = game:GetService("MarketplaceService") 

db = true
function onTouch(part)
	local humanoid = part.Parent:FindFirstChild("Humanoid")
	local player = game.Players:GetPlayerFromCharacter(part.Parent)
	if db == true and humanoid ~= nil and (mps:UserOwnsGamePassAsync(player.UserId, 4897628) ~= nil) then
	db = false
	wait(0.24)
	part.Parent:MoveTo(teleport.Position)
	wait(0.5)
	db = true
	end
	end

script.Parent.Touched:connect(onTouch)

1 comment

0

You didn't make a condition for if the player doesn't own the gamepass. Move the teleport code into an else statement for if the player doesn't own the gamepass.

2 answers

✓ Accepted answer
local teleport = game.Workspace.SpecialPart1
mps = game:GetService("MarketplaceService") 

db = true

function onTouch(part)
	local humanoid = part.Parent:FindFirstChild("Humanoid")
    local player = game.Players:GetPlayerFromCharacter(part.Parent)
	local HasGamePass = mps:UserOwnsGamePassAsync(player.UserId, 4897628) -- returns true if you have the gamepass
    if db == true and humanoid ~= nil and not HasGamePass then
		db = false
    	wait(0.24)
    	part.Parent:MoveTo(teleport.Position)
    	wait(0.5)
    	db = true
	end
end

script.Parent.Touched:Connect(onTouch) -- connect is deprecated

No need to add ~= nil:

mps:UserOwnsGamePassAsync(player.UserId, 489762)

--You can use this as well:
mps:PlayerOwnsAsset(player.UserId, 489762)

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