Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago

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

Log in to vote
1
Answered by
6zk8 95
4 years ago
Edited 4 years ago
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.

0
it says music status is not a member of player gui but i see it in my player gui Fr0stPh3onix 79 — 4y
0
i just accepted because idk Fr0stPh3onix 79 — 4y
1
it should work now^ 6zk8 95 — 4y
1
i edited it 6zk8 95 — 4y
View all comments (4 more)
Ad
Log in to vote
0
Answered by 4 years ago

.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!

Answer this question