Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

[UDim2] Part Health Script Please Help? :D

Asked by 9 years ago

So I made a script that changes a value and now I want the GUI to change Colors when it goes below a certain number :D

while true do
    wait()
    script.Parent.Text = game.Lighting.Value.Value
    if game.Lighting.Value.Value <= 10 then
        script.Parent.BackgroundColor3 = UDim2.new(221, 0, 3)
    end
end
--Output
--[Players.Player1.PlayerGui.ScreenGui.TextLabel.sc:5: attempt to index field 'BackgroundColor3' (a nil value)

1
UDim2 adjusts the dimension, not color. Use Color3.new(221/255,0/255,3/255) instead. Redbullusa 1580 — 9y
0
I put Color3.new(221/255, 0/255, 3/255) instead of Color3.new(221, 0, 3) because a Color3Value has a set of elements (3) that can go between 0 and 1. Redbullusa 1580 — 9y

1 answer

Log in to vote
-1
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
9 years ago

You're using the wrong object constructor!

What you're looking for is Color3.new(). Try that instead. :)

Ad

Answer this question