I want to change the GUI's text to cash, but it never changes and gives no errors. The leaderstats changes but the GUI does not. The script is located in starter character scripts.
wait(1) local playerModel = script.Parent local player = game.Players:GetPlayerFromCharacter(playerModel) player:WaitForChild("leaderstats") player.leaderstats:WaitForChild("Cash") local cash = player.leaderstats.Cash local moneyText = player.PlayerGui.ScreenGui.moneyLabel.Text while true do wait(5) cash.Value = cash.Value + 100 moneyText = cash.Value end
Does anyone know how to fix this? Thanks in advance!
You set the Variable moneyText
to player.PlayerGui.ScreenGui.moneyLabel.Text
but Lua just Sets the variable to the property and when you set it it only changes the Variable itself. Not the actual property.
Replace player.PlayerGui.Screengui.moneyLabel.Text
with player.PlayerGui.Screengui.moneyLabel
. And replace moneyText = cash.Value
to moneyText.Text = cash.Value
wait(1) local playerModel = script.Parent local player = game.Players:GetPlayerFromCharacter(playerModel) player:WaitForChild("leaderstats") player.leaderstats:WaitForChild("Cash") local cash = player.leaderstats.Cash local moneyText = player.PlayerGui.ScreenGui.moneyLabel while true do wait(5) cash.Value = cash.Value + 100 moneyText.Text = cash.Value end