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

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

Asked by 5 years ago

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)

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. Pojoto 329 — 5y

2 answers

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago
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
Ad
Log in to vote
0
Answered by
hellmatic 1523 Moderation Voter
5 years ago

No need to add ~= nil:

mps:UserOwnsGamePassAsync(player.UserId, 489762)

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

Answer this question