Im trying to achieve label that shows multipliers

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve?
    i want to achieve a multiplier system for my gems in game

  2. What is the issue?
    it works its just the loop is cause lag idk if there way to this without the while wait()

  1. What solutions have you tried so far? Did you look for solutions on the Creator Hub?

still looking for solution

local player = game.Players.LocalPlayer
local module = require(game.ReplicatedStorage.Abbreviations)


local id = 24229407

while task.wait() do
	if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,id) then
		script.Parent.Text = "Gems x "..module.abbreviate(player.RankMultiplier.Value * 2 * player.Level.Value)
	else
		script.Parent.Text = "Gems x "..module.abbreviate(player.RankMultiplier.Value * player.Level.Value)
	end
end

Why are you using a while loop for this logic? You can just update it when the player joins the experience and when they purchase your gamepass.

game:GetService("MarketplaceService").PromptGamePassPurchaseFinished:Connect(function(plr, id, wp)
    if wp then
        -- woah they bought the gamepass
        -- actually i reread the docs you should probably check if they own the gamepass
        if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId, id) then
            -- ok they definitely own the gamepass now
        end
     end
end
1 Like

You’re super close! The second value passed from PromptGamePassPurchaseFinished is actually the gamepass asset id. The @OP could compare the asset id against their gamepass id, and do the change from there. The only caveat that I can foresee though is that this may only be server-sided.

local GamepassId = 24229407


local MarketplaceService = game:GetService("MarketplaceService")

local function GamePassPurchased(Customer, AssetId, WasPurchased)
	if WasPurchased and AssetId == GamepassId then
		-- code
	end
end

MarketplaceService.PromptGamePassPurchaseFinished:Connect(GamePassPurchased)
1 Like

Have a singular script manage all the changes of currency. When you want to add currency or remove currency you can call a remote to that. For multipliers you can check if the player has the certain gamepass that boosts multiplier. If they do have this gamepass store that information in that currency manager so that whenever you add currency you append that multiplier too