Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Whenever I earn money in my game it doesn't update?

Okay, so whenever I earn money in my game it updates in the value but not in the Gui. Here is the script:

Money = script.Parent.Parent.Money
local s = Instance.new("ScreenGui")
s.Parent = script.Parent
local m = Instance.new("TextLabel")
m.Parent = s
m.BackgroundTransparency = 1
m.Position = UDim2.new(0,0,0,400)
m.Size = UDim2.new(0,200,0,50)
m.Font = "Legacy"
m.FontSize = "Size24"
m.TextColor3 = Color3.new(36,216,48)
m.Text = "$" .. Money.Value

If you can help, thank you!

1 answer

✓ Accepted answer

Using the code you already provided, we can add a .Changed event that runs whenever Money's value changes.

Money = script.Parent.Parent.Money
local s = Instance.new("ScreenGui")
s.Parent = script.Parent
local m = Instance.new("TextLabel")
m.Parent = s
m.BackgroundTransparency = 1
m.Position = UDim2.new(0,0,0,400)
m.Size = UDim2.new(0,200,0,50)
m.Font = "Legacy"
m.FontSize = "Size24"
m.TextColor3 = Color3.new(36,216,48)
m.Text = "$" .. Money.Value

Money.Changed:connect(function() -- When money's value changes, run the contained function
	m.Text = "$"..Money.Value -- Changes the text to reflect the change
end) -- End the function

Changed Event

1 comment

0

Thank you! It worked

This discussion is preserved as it was. New answers, comments, and votes are closed.