I have a script and the value of Cash is supposed to change to 999999999if u have a gamepass, and if u dont then it will just be Cash.Value, it doesnt work thought and idk why, can somebody please help me, thank you!
Output:
14:45:57.206 - Script 'Players.PurpleProgram.PlayerGui.CashGUI.Cash.Label.LocalScript', Line 7
local player = game.Players.LocalPlayer
local cash = player:WaitForChild("leaderstats").Cash
local id = 8068400
local service = game:GetService("MarketplaceService")
while wait(0.1) do
if service:UserOwnsGamePassAsync(player, id) then
cash.Value = 9999999999
script.Parent.Text = "Infinite"
else
script.Parent.Text = cash.Value
end
end
service.PromptGamePassPurchaseFinished:Connect(function(player,ido,purchased)
if purchased and ido == id then
wait (1)
cash.Value = 9999999999
script.Parent.Text = "Infinite"
else
script.Parent.Text = cash.Value
end
end)

4 comments
Is this a local script or server script?
Local
Leaderstats can only be accessed by the server, so you need to use a RemoteEvent to send a message to the server to update the player's currency.
example?