I’m having this issue with my text and value, all the print statements are working, but the text does not change, and it can’t move down to the part where if the value is above 2000 it displays the message on the board.
I’m not sure what’s going wrong, so could someone help? Thanks.
local text = script.Parent.TextLabel.Text
local tempa = game.Workspace.CORE.CORE.Temperature.Value
local function temp ()
print("temp changed")
if tempa <= 2000 then
text = tempa
print("text changed")
else if tempa > 2000 then
print ("Mooltdown")
text = "MELTDOWN IMMINENT! EVACUATE IMMEDIATELY!"
print("RUN!")
end
end
end
game.Workspace.CORE.CORE.Temperature.Changed:Connect(temp)
local text = script.Parent.TextLabel
local tempa = game.Workspace.CORE.CORE.Temperature.Value
local function temp ()
print("temp changed")
if tempa <= 2000 then
text.Text = tempa
print("text changed")
else if tempa > 2000 then
print ("Mooltdown")
text.Text = "MELTDOWN IMMINENT! EVACUATE IMMEDIATELY!"
print("RUN!")
end
end
end
game.Workspace.CORE.CORE.Temperature.Changed:Connect(temp)
Edit: Essentially what your script did was assign text the string stored in the text label, so when you set text = tempa, you just set it to a different string and not the textlabel.
Yeah, it’s working now. Odd, shouldn’t it be the same thing?
But now, I’m running into another issue. It only updates once.
I shortened the code to make sure it wasn’t the else if portion, but the issue remains/
local text = script.Parent.TextLabel
local tempa = game.Workspace.CORE.CORE.Temperature.Value
local function temp ()
print("temp changed")
if tempa <= 2000 then
text.Text = tempa
print("text changed")
end
end
game.Workspace.CORE.CORE.Temperature.Changed:Connect(temp)
You see anything wrong with it?
EDIT: deleted a lot of the code, left only the changing part, still not working. I am quite confused.
Just from looking at it I don’t see anything wrong with it. I don’t know if this is it but maybe try wrapping tempa in a toString() since tempa appears to be an int and text holds a string.
Yeah, only changes once. The starting value is 1990, then it moves to 91. Script picks it up and sets value as 1990. Then it doesn’t change as it moves to 92.
If I case it in a when true loop, the value is set to 1990 immediately, but doesn’t change after that.
Looking at the API reference, the function call has a parameter for the value so maybe you should try changing it to look like this where it utilizes the parameter instead of the tempa variable.
local text = script.Parent.TextLabel
local function temp (tempa)
print("temp changed")
if tempa <= 2000 then
text.Text = tostring(tempa)
print("text changed")
end
end
game.Workspace.CORE.CORE.Temperature.Changed:Connect(temp)
You’re referencing the properties themselves not the objects, causing them to remain constant. Instead replace your current code with:
local text = script.Parent.TextLabel --not .Text!
local tempa = game.Workspace.CORE.CORE.Temperature --not .Value!
local function temp()
print("temp changed")
if tempa.Value <= 2000 then
text.Text = tempa
print("text changed")
--it's elseif without space not else if!
elseif tempa.Value > 2000 then
print ("Meltdown")
text.Text = "MELTDOWN IMMINENT! EVACUATE IMMEDIATELY!"
print("RUN!")
end
end
temp()
tempa.Changed:Connect(temp)