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

how do i make a script that detects when a value has changed?

im trying to make a script that will tell you what music is playing. so the text will be the same as the status but how do i make a script that checks if status has changed? this is what i tried

local status = game.StarterGui.MusicStatus
local text = script.Parent

status.Value.Changed:Connect(function()
	text.Text = status
end)

2 answers

local player = game.Players.LocalPlayer

local status = player.PlayerGui:WaitForChild("MusicStatus")
local text = script.Parent

status.Value.Changed:Connect(function()
    text.Text = status
end)

You didn't use PlayerGui.

8 comments

0

it says music status is not a member of player gui but i see it in my player gui

0

i just accepted because idk

1

it should work now^

1

i edited it

1

It should work

0

now it says attempt to index nil with 'Connect' line 6?

1

Are you sure .Value.Changed is a event?

.Changed only works with string values. Insert a string value into ReplicatedStorage first. You can name it Status. Then you can change its value any time. Replace your script with this (make sure it's a LocalScript as well):

local status = game.ReplicatedStorage:WaitForChild("Status")
local text = script.Parent

text.Text = status.Value

status.Changed:Connect(function()
	text.Text = status.Value
end)

Hope this helps!

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