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

Value Color Changing not working?

The purpose of this script is for the block this script is in, if the value labeled resources, is 1000 it will be 1000, it will be 1 color, and if its 900 it will be another color, for some reason, i Don't get any errors, but the colors wont change. Please help me out! Thanks for reading.

if workspace.Resources.Value == 1000 then
script.Parent.BrickColor = BrickColor.new("Bright green")
elseif workspace.Resources.Value == 900 then
script.Parent.BrickColor = BrickColor.new("Br.yellowish green")	
end

1 answer

✓ Accepted answer

Well, there are 2 ways you can solve your problem. By using a Changed event, or a loop. I'll show both. The reason yours doesn't work, is because it doesn't know when to check if the value is 1000 or 900!

Changed:

game.Workspace.Resources.Changed:connect(function()
	if game.Workspace.Resources.Value == 1000 then
		script.Parent.BrickColor = BrickColor.new("Bright green")
	elseif game.Workspace.Resources.Value == 900 then
		script.Parent.BrickColor = BrickColor.new("Br.yellowish green") -- Heh, I've never seen that. Make sure spelling is correct!
	end
end)

Loop:

while wait() do
	if game.Workspace.Resources.Value == 1000 then
		script.Parent.BrickColor = BrickColor.new("Bright green")
	elseif game.Workspace.Resources.Value == 900 then
		script.Parent.BrickColor = BrickColor.new("Br.yellowish green")
	end
end

2 comments

0

Thanks for helping me! and for all your support :D!

0

No problem!

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