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

Help with joining VIP script? [closed]

Asked by 9 years ago
local vipPass = 231935192
local ultraVipPass = 231935475

game.Players.PlayerAdded:connect(function(player)
    if game.GamePassService:PlayerHasPass(player, ultraVipPass) then
        local cashmoney = game.ServerStorage.MoneyStorage:WaitForChild(player.Name)
        if cashmoney then
            cashmoney.Value = cashmoney.Value + 10000
        end
        player.CharacterAdded:connect(function(char)
            if char:WaitForChild("Humanoid") then
                char.Humanoid.MaxHealth = 200
                char.Humanoid.Health = 200
                char.Humanoid.WalkSpeed = char.Humanoid.WalkSpeed + 4
            end
        end)
    elseif game.GamePassService:PlayerHasPass(player,vipPass) then
        local cashmoney = game.ServerStorage.MoneyStorage:WaitForChild(player.Name)
        if cashmoney then
            cashmoney.Value = cashmoney.Value + 5000
        end
        player.CharacterAdded:connect(function(char)
            if char:WaitForChild("Humanoid") then
                char.Humanoid.MaxHealth = 150
                char.Humanoid.Health = 150
            end
        end)
    end
end)

I have this script inside ServerScriptStorage and I was whenever a VIP joins a server they get all the perks. It works, but if you leave and rejoin the same server then you don't get these perks. How can I make it so you get these perks every time you enter a new server as well as the same server you were in a few minutes ago?

Locked by NinjoOnline, Goulstem, and Redbullusa

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

1 answer

Log in to vote
2
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
9 years ago

There's no reason why they shouldn't get this when they rejoin, but I can point out a few errors

1) - I HIGHLY suggest using the PlayerOwnsAsset function, rather than the PlayerHasPass function. Because it returns live results from the website, while the PlayerHasPass function returns cached results. Meaning you won't have to rejoin the game to get the effects if you bought the gamepass during gameplay.

2) - You're giving the character a health boost no matter what, conditionals do NOT effect whether or not events fire! meaning that your CharacterAdded event will fire reguardless of if the conditional is true or false, hence you getting a health boost no matter what.

local vipPass = 231935192
local cashStorage = game.ServerStorage.MoneyStorage
local cashAwarded = false
--edit--
local ms = game:GetService('MarketplaceService')
--edit--

game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(char)
        if ms:PlayerOwnsAsset(player,vipPass) and not cashAwarded then
            local cash = cashStorage:FindFirstChild(char.Name)
            if cash then
                cash.Value = cash.Value + 5000
                cashAwarded = true
            end
            local hum = char:WaitForChild('Humanoid')
            --edit[2]--
            hum.MaxHealth = 150
            hum.Health = 150
            --edit[2]--
        end
    end)
end)
0
it says ms is unknown global? NinjoOnline 1146 — 9y
0
and another thing. I have two VIPs, I only used one. How can I get it to work so it works for both a VIP and UltraVIP. I have editted my answer with my original with both vips. NinjoOnline 1146 — 9y
0
Sorry I didn't define ms. Goulstem 8144 — 9y
0
Should my thing actually work without any problems? I think its cause of the moneystorage in ServerStorage, but idk. I just want if you leave and rejoin that same server you get the cash and health again NinjoOnline 1146 — 9y
View all comments (6 more)
0
I'm not going to help with adding another VIP to it since it's not your original question. This code should work perfectly.. what errors are you getting? Goulstem 8144 — 9y
0
there are no errors NinjoOnline 1146 — 9y
0
I have one problem though, when you join , your maxhealth changes to 150, BUT your health dosent, so you start of with half your health and have to wait till it gets to 150 NinjoOnline 1146 — 9y
0
What do you mean 'wait' until it gets to 150? It should change with little to no yeild from when the character spawn Goulstem 8144 — 9y
0
well the character spawns with 100 health and 150 max health, so the player has to wait for it to load NinjoOnline 1146 — 9y
0
Sorry, it's because I defined the health before the MaxHealth was defined. I edited it so it should work now(: Goulstem 8144 — 9y
Ad