You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
I am making a VIP gamepass give 1.5x coins and xp but am having trouble with figuring out a way to update the loop when a player buys the gamepass in game. It works fine when they rejoin.
- What is the issue? Include screenshots / videos if possible!
The issue is that I do not know how to update the multiplier in the loop.
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have looked for solution on the devhub and cannot find anything, I have tried to search things on the devforum and none of them help with my issue. Everything works fine besides when the player buys it in game.
game.Players.PlayerAdded:Connect(function(player) local PlayerStats = player:WaitForChild('PlayerStats') local XP = PlayerStats:WaitForChild('XP') local Coins = PlayerStats:WaitForChild('Coins') local CoinsVIPMulti = PlayerStats:WaitForChild('CoinsVIPMulti') local XPVIPMulti = PlayerStats:WaitForChild('XPVIPMulti') local CoinsPremiumMulti = PlayerStats:WaitForChild('CoinsPremiumMulti') local XPPremiumMulti = PlayerStats:WaitForChild('XPPremiumMulti') CoinsVIPMulti = 1 XPVIPMulti = 1 CoinsPremiumMulti = 0 XPPremiumMulti = 0 if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,27136394) then CoinsVIPMulti = 1.5 XPVIPMulti = 1.5 end game:GetService("MarketplaceService").PromptGamePassPurchaseFinished:Connect(function(player, id, purchased) if id == 27136394 and purchased then CoinsVIPMulti.Value = 1.5 XPVIPMulti.Value = 1.5 end end) if player.MembershipType == Enum.MembershipType.Premium then CoinsPremiumMulti = 0.5 XPPremiumMulti = 0.5 end local TotalCoinsMulti = CoinsVIPMulti + CoinsPremiumMulti local TotalXPMulti = XPVIPMulti + XPPremiumMulti while true do Coins.Value += 5 * TotalCoinsMulti XP.Value += 5 * TotalXPMulti wait(2) end end)
I think that the PromptGamePassPurchaseFinished is not activating because of the loop. I somewhat new to scripting so thanks for any help in advance.