Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

[UDim2] Part Health Script Please Help? :D

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)

2 comments

1

UDim2 adjusts the dimension, not color. Use Color3.new(221/255,0/255,3/255) instead.

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.

1 answer

✓ Accepted answer

You're using the wrong object constructor!

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

This discussion is preserved as it was. New answers, comments, and votes are closed.