Help with GamePass Script

  1. What do you want to achieve? Just a simple gamepass that gives 500 coins

  2. What is the issue? Okay, so. The script and gamepass itself works but…The GUI that also has the coin currency is not changing…

  3. What solutions have you tried so far? None. :heart:

-- local CoinText = script.Parent.Parent.Workspace.Parent.StarterGui.CoinGUI.Frame.Parent.CoinAmount



local gamepassId = 10805450
local stat = "Coins"
local gamepassStat = 500


game.Players.PlayerAdded:Connect(function(player)
	
	local leaderstats = Instance.new("Folder",player)
	leaderstats.Name = "leaderstats"
	local val = Instance.new("IntValue", leaderstats)
	
	val.Name = "Coins"
	val.Value = 100
	
	
	
	local awarded = Instance.new("BoolValue", player)
	awarded.Name = "Awarded"
	
	if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, gamepassId) and player.Awarded.Value == false then
		player.Awarded.Value = true
		val.Value = val.Value + gamepassStat
		CoinText.Text = "Coins:" .. val.Value -- NOT WORKING
	end
	
	
	

end)

while wait(3) do
	for i, v in pairs(game.Players:GetChildren()) do
		if game:GetService("MarketplaceService"):UserOwnGamePassAsync(v.UserId, gamepassId) and v:WaitForChild("Awarded").Value == false then
			v.Awarded.Value = true
			v.leaderstats:FindFirstChild(stat).Value = v.leaderstats:FindFirstChild(stat)
		end
	end
end

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

You want to move the CoinText variable down below the player added function and change it to

local CoinText = player.PlayerGui.CoinGui.Frame.Parent.CoinAmount

I moved it to a local script under the GUI. And it worked. But, this could also work too.

Ya either way will do the trick

1 Like