I have a block that changes color and text when it the tool is in use. It doesn't work, even though the tool has its bool value changed to true. Anyone know how to fix this?
InUse = game.ServerStorage.Key1.InUse.Value while true do if InUse == true then script.Parent.BrickColor = BrickColor.new("Really red") script.Parent.SurfaceGui.TextLabel.Text = "Key1: In Use" wait(1) elseif InUse == false then script.Parent.BrickColor = BrickColor.new("Bright green") script.Parent.SurfaceGui.TextLabel.Text = "Key1: Not In Use" wait(1) end end
Mostly issues occur from efficiency problems, in this case, this is probably what's causing your problem. @theking is right, tools
have an equipped
and unequipped
event. It's best to use these to your advantage. For example...
local tool = --//Index your tool local handle = --// index handle local gui = --//Index GUI local colors = {"Really red", "Bright green"} --//Optional handle.BrickColor = BrickColor.new(colors[1]) --//Assuming 'handle' is the object being colored tool.Equipped:Connect(function() handle.BrickColor = BrickColor.new(colors[2]) gui:WaitForChild("TextLabel").Text = "Key1: In Use" --// Efficiency tip: Sometimes the script can run faster than the asset can load, so we yield it until it exists, this should be used to index most things. end) tool.Unequipped:Connect(function() handle.BrickColor = BrickColor.new(colors[1]) gui:WaitForChild("TextLabel").Text = "Key1: Not In Use" end)
Hope this fixes your problem