#TextLabel not changing for whatever reason

1 messages · Page 1 of 1 (latest)

craggy pendant
#
local TextLabel = script.Parent
local Text = TextLabel.Text
local Power = workspace.OfficeCorridors.Desk.Buttons.PowerManager.PowerAmount
local Light1 = TextLabel.Parent.Parent.PointLight
local Light2 = TextLabel.Parent.Parent.SurfaceLight

local Green = Color3.new(0, 1, 0)
local Lime = Color3.new(0.5, 1, 0)
local Yellow = Color3.new(1, 1, 0)
local Orange = Color3.new(1, 0.5, 0)
local Red = Color3.new(1, 0, 0)

while task.wait(0.1) do
    Text = tostring(math.round(Power.Value)).."%"
    if Power.Value > 80 then
        TextLabel.TextColor3 = Green
        Light1.Color = Green
        Light2.Color = Green
    elseif Power.Value > 60 then
        TextLabel.TextColor3 = Lime
        Light1.Color = Lime
        Light2.Color = Lime
    elseif Power.Value > 40 then
        TextLabel.TextColor3 = Yellow
        Light1.Color = Yellow
        Light2.Color = Yellow
    elseif Power.Value > 20 then
        TextLabel.TextColor3 = Orange
        Light1.Color = Orange
        Light2.Color = Orange
    elseif Power.Value < 20 then
        TextLabel.TextColor3 = Red
        Light1.Color = Red
        Light2.Color = Red
    end
end```
lunar orbit
#

so the variable power is itself the value of power

#

u gotta do

local Power = workspace.OfficeCorridors.Desk.Buttons.Power

little thorn
#

you are updating the variable text not changing the actual property

craggy pendant
#

wait I'll change the name so its easier to read

lunar orbit
#

we know

craggy pendant
#

no youre still wrong

#

the power

#

is a script

#

and the value is a int value

lunar orbit
#

wdym

#

it doesnt matter if Power is a script or value

craggy pendant
#

I fixed it

little thorn
#

the intvalue was named value

craggy pendant
#

yes

little thorn
#

which is confusing

lunar orbit
#

the main thing was that he was referencing the value as a var and then he was trying to get the value of a value

craggy pendant
#

I was not

lunar orbit
#

oh wait sry

#

i didnt know u were the original guy posting this

#

im stupid

craggy pendant
#

Its ok

little thorn
#

the instance's name was value so that code was correct, whats not right is the way youre updating the textlabel's text

little thorn
#

you can't just say local text = textlabel.text
text will only store the text thats inside the text label, not act as a reference to the property

craggy pendant
#

oh yeah

#

I forgot

little thorn
#

that means if you have a textlabel with the word "text", and you had a variable called text, it would be equal to "text"

safe basin
#

are you sure its not changing because you're doing > comparing the power value to lower numbers

tawny lagoonBOT
#

studio** You are now Level 3! **studio