I’m making a simple sword fighting game. The gui script that I wrote does not work as intended.
local Status = game:GetService("ReplicatedStorage"):WaitForChild("Status")
script.Parent.text = Status.Value
Status:GetPropertyChangedSignal("Value"):Connect(function(Status)
script.Parent.text = Status.Value
print("Change")
end)
I need someone to tell me what I did wrong. The script is a local script that is pulling a value from the string “status” and changing the text on the gui to what the string status is. While the game is running the status changes but not the gui. The 3rd line of code is for pulling the status when the game opens, but after it pulls the string there it does not pull it anymore.
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.
Try it without the “Value” in GetPropertyChangedSignal(“Value”)
iirc. “Value” is the default thing for all the *Value instances, so you wouldn’t need to specify it and might be overriding it somehow.
Fixed! I tested this out in my own place and discovered that your function parameter is overlapping with your variable.
local Status = game:GetService("ReplicatedStorage"):WaitForChild("Status")
script.Parent.Text = Status.Value
Status:GetPropertyChangedSignal("Value"):Connect(function() -- I removed "Status" in the function parameter, it works just fine without
script.Parent.Text = Status.Value
print("Change")
end)
Status.Value = 2 -- Original value = 1