Alright. Let’s start with a bit of a tip: Try to avoid using while loops for things like this. Instead, try a :GetPropertyChangedSignal() event:
player:WaitForChild("leaderstats"):WaitForChild("Cash"):GetPropertyChangedSignal("Value"):Connect(function()
-- code here
end)
And now for your solution: Integers and Strings are different kinds of ways to store information. You can, and in this case should, use tostring(player.leaderstats.Cash.Value) to turn that number into text.
Probably because it runs before the cash loads (I’m assuming from the single script), try using waitforchild. Also, try turning the number into a string.
while wait() do
player = game.Players.LocalPlayer
local cash = player:WaitForChild("leaderstats"):WaitForChild("Cash")
script.Parent.Text = ("$" ..tostring(cash.Value)
end
Edit: I also agree with @d_ytme on not using while loops and instead using :GetProperyChangedSignal() or using the .Changed event. So:
player:WaitForChild("leaderstats"):WaitForChild("Cash").Changed:Connect(function()
player = game.Players.LocalPlayer
local cash = player:WaitForChild("leaderstats"):WaitForChild("Cash")
script.Parent.Text = ("$" ..tostring(cash.Value)
end)
now its saying
Players.SakDevRblx.PlayerGui.Coin Flip.coin flip.top.Cash amount.Script:1: attempt to index nil with ‘WaitForChild’
edit also its ("$" …tostring(cash.Value))
not
("$" …tostring(cash.Value)
the script is parented to the a text label and the text label is inside of a folder in startergui
edit: just in case i wrote script wrong this is most current:
local Players = game:GetService("Players")
local player = Players.LocalPlayer
player:WaitForChild("leaderstats"):WaitForChild("Cash").Changed:Connect(function()
local cash = player:WaitForChild("leaderstats"):WaitForChild("Cash")
script.Parent.Text = "$"..player.Cash.Value
end)
local Players = game:GetService("Players")
local player = Players.LocalPlayer
player:WaitForChild("leaderstats"):WaitForChild("Cash").Changed:Connect(function(value)
script.Parent.Text = "$"..tostring(value)
end)
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local cash = player:WaitForChild("leaderstats"):WaitForChild("Cash")
script.Parent.Text = "$"..tostring(cash.Value)
cash.Changed:Connect(function(value)
script.Parent.Text = "$"..tostring(value)
end)
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local cash = player:WaitForChild("leaderstats"):WaitForChild("Cash")
script.Parent.Text = $..tostring(cash.Value)
cash.Changed:Connect(function(value)
script.Parent.Text = "$"..tostring(value)
end)
correct form:
local Players = game:GetService(“Players”)
local player = Players.LocalPlayer
local cash = player:WaitForChild(“leaderstats”):WaitForChild(“Cash”)
script.Parent.Text = “$”…tostring(cash.Value)
cash.Changed:Connect(function(value)
script.Parent.Text = “$”…tostring(value)
end)