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

How do I let players w/ higher tiered VIPs go into VIP rooms for lower tiered VIPs?

Asked by 7 years ago

I'm having trouble making a system where a player w/ a high tier VIP game pass is able to go into a room that's accessible to lower tiered VIPs.

Example: Let's say a player bought a VIP game pass that's called Mega VIP. That player who bought Mega VIP should also get access to the VIP tier below Mega VIP, called Normal VIP.

How would I let the player that bought Mega VIP also get access to Normal VIP which is a "lower tier" than Mega VIP? (Hope I didn't sound too redundant with this question.)

Here's my script: (Does not work)


local Config = script.Parent.Configuration local Gamepass = Config.GamepassId.Value local Group = Config.GroupId.Value local Gamepass2 = Config.GamepassId2.Value local Kill = Config.KillOnTouch.Value local Door = script.Parent.Door Door.Transparency = 0 Door.CanCollide = true function AllowedIn(Player) if Player.userId == 0 then return false elseif Gamepass or Gamepass2 > 0 then if game.MarketplaceService:PlayerOwnsAsset(Player,Gamepass or Gamepass2) then return true end elseif Group > 0 then if Player:IsInGroup(Group) then return true end end return false end local Debounce = true Door.Touched:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then local Player = game.Players:GetPlayerFromCharacter(hit.Parent) if Player and Debounce then Debounce = false if AllowedIn(Player) then Door.CanCollide = false Door.Transparency = 0.5 spawn(function() wait(1.5) Door.CanCollide = true Door.Transparency = 0 end) else if Gamepass or Gamepass2 > 0 then game.MarketplaceService:PromptPurchase(Player,Gamepass) end if Kill then hit.Parent.Humanoid.Health = 0 local Explosion = Instance.new("Explosion",workspace) Explosion.BlastPressure = 0 Explosion.Position = hit.Position else if hit.Parent:FindFirstChild("Torso") then hit.Parent.Torso.Velocity = Door.CFrame.lookVector * 150 end end end wait(0.3) Debounce = true end end end)

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

I cleaned up your code and made it a bit easier to understand with comments and general style. I changed it from more of a manual system to a bit more automatic in terms of creating the AllowedIn function.

The general way my changes work is that they check if the VIP level of a player is bigger than or equal to the level of a door. The majority of the changed code is simply setting it up, as the actual checking of the level is very simple!

local Pass1 = 0000 -- VIP
local Pass2 = 0000 -- Mega VIP
local Group = 0000

local Marketplace = game:GetService("MarketplaceService")
local PlayerLevels = {} -- easy to access table of VIP levels

game.Players.PlayerAdded:connect(function(Player) -- this function assigns the VIP level of a player
    local Level = 0

    if Player:IsInGroup(Group) then
        Level = 3 -- make sure the levels descend
    elseif Marketplace:PlayerOwnsAsset(Player,Pass2) then -- do these in descending order of tier
        Level = 2
    elseif Marketplace:PlayerOwnsAsset(Player,Pass1) then
        Level = 1
    end

    PlayerLevels[Player.UserId] = Level -- Sets the value
end)

local function AllowedIn(Player,MinLevel) -- MinLevel is the minimum VIP level required to enter
    if PlayerLevels[Player.UserId] >= MinLevel then -- the `Table[Index]` is a way of getting a value in a table similar to searching a library for a book with a specific name
        return true
    else
        return false
    end
end

local Debounce = true
Door.Touched:connect(function(Hit)
    local Player = game.Players:GetPlayerFromCharacter(Hit.Parent) or game.Players:GetPlayerFromCharacter(Hit.Parent.Parent) -- R15 compatible
    if not Player or not Debounce then return end -- Finish if player wasn't found or debounce is happening

    if AllowedIn(Player,1) then -- Assuming this is a VIP door
        Debounce = false
        Door.CanCollide = false
        Door.Transparency = 0.5
    else
        Marketplace:PromptPurchase(Player,Gamepasses1) -- assuming this is a VIP door
        -- Kill stuff
    end

    wait(1.5)
    Door.CanCollide = true
    Door.Transparency = 0
    Debounce = true
end)

Anything you don't understand? Please tell me :) Hope I could help!

~TDP

Ad

Answer this question