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?
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)
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?