i have a value in my tool, and every time it changes, the text in the tool will change according to the value number, i tried printing, and the printing did not go through, i tried making it a local script, but it still doesn’t work. there is no error so i don’t really know what i did wrong here, heres the script:
wait()
local value = script.Parent.Value
script.Parent.Handle.Bill.TextLabel.Text = value.Value
value.Changed:Connect(function()
print("changed")
script.Parent.Handle.Bill.TextLabel.Text = value.Value
end)
It doesnt work by directly placing the value of the variable, but simply the variable
can you put the script inside the value? – and you change the other line
wait()
local value = script.Parent
script.Parent.Handle.Bill.TextLabel.Text = value.Value
value.Changed:Connect(function()
print("changed")
script.Parent.Handle.Bill.TextLabel.Text = value.Value
end)
I think I was wrong, calling it value makes it so confusing, youd better leave it as it was before, I think the problem is that you arent changing the value at any time and if you have already done it you should declare local value first before changing it, then you do the function
No, that is not the source of the issue (Just for the thing though, Int values can only hold integers while Number values can hold floats). The thing is, you are not referencing the value holder instance but rather it’s value. Assuming it’s value was 0, you are doing 0.Changed, .Changed is not a valid member of 0.
Consider changing your code to:
wait()
local valueInstance = script.Parent
local value = valueInstance.Value
script.Parent.Handle.Bill.TextLabel.Text = value
valueInstance.Changed:Connect(function()
print("changed")
script.Parent.Handle.Bill.TextLabel.Text = value
end)
local value = script.Parent
function changeValue()
script.Parent.Handle.Bill.Text = tostring(value.Value)
print("Changed!")
end
value:GetPropertyChangedSignal("Value"):Connect(function()
changeValue()
end)
Are you trying to change a text of a gui to everyone in the server (so everyone can see it)?
if thats the case you could fire an event when the value has changed, so fire a event on local script, make server script react on server event and change the gui text for everyone in the game.