Hello, I am struggling to make a script where the text label shows the value of a bool value in the text.
I have tried for a while and out lots of effort into trying to fix this but just can’t. Can someone help me?
Here is my code.
local replicatedStorage = game:GetService(“ReplicatedStorage”)
local Status = replicatedStorage:WaitForChild(“Status”)
local topStatus = script.Parent:WaitForChild(“TopStatus”)
I think you can just use Status.Changed since it’s a valueObject. You don’t need to use GetService with ReplicatedStorage either. In order to transfer a boolean into text use tostring(). example: topStatus.Text=tostring(Status.Value)
Not the issue, :GetPropertyChangedSignal("Value") will do the job.
Also, I believe you can’t display boolean values in TextLabels right away. You need to convert the boolean value to a string before setting it as the text.
local replicatedStorage = game:GetService("ReplicatedStorage")
local Status = replicatedStorage:WaitForChild("Status")
local topStatus = script.Parent:WaitForChild("TopStatus")
topStatus.Text = tostring(Status.Value)
Status:GetPropertyChangedSignal("Value"):Connect(function()
topStatus.Text = tostring(Status.Value)
end)
Also not sure about this thing, I haven’t tested this out yet.
P.S: Also, next time when posting a script, use 3 backticks ( ` ) at the beginning and the end and paste your code between them. It will be more legible.
I used a LocalScript and used this code, and it didn’t work so what’s the problem?
local Status = replicatedStorage:WaitForChild("Status")
local topStatus = script.Parent:WaitForChild("TopStatus")
Status.Changed:Connect(function(p)
if p == "Value" then
topStatus.Text = tostring(Status.Value)
end
end)