This script has to do some stuff with a gui I made if the values change. But it doesn't do anything
local plyr = script.Parent.Parent.Parent
local tool = plyr.Tool
local ammo = plyr.Tool.Ammo
local gui = script.Parent
local armor = plyr.Armor
local clip = plyr.Tool.Clip
while true do
if tool.Value == "Hands" then
gui.Index.Screen.Title.Text = "Hands - No Tool"
gui.Index.Screen.Ammo.Visible = false
gui.Index.Screen.Ammo2.Visible = false
gui.Index.Screen.Controls.Visible = false
gui.Index.Screen.LEFT.Visible = false
gui.Index.Screen.RIGHT.Visible = false
gui.Index.Screen.MODE.Visible = false
gui.BG:TweenPosition(UDim2.new(1, -325, 1, -75))
gui.Index:TweenPosition(UDim2.new(1, -310, 1, -60))
elseif tool.Value == "Test" then
gui.Index.Screen.Title.Text = "Test - ammothing"
gui.Index.Screen.Ammo.Visible = true
gui.Index.Screen.Ammo2.Visible = false
gui.Index.Screen.Controls.Visible = true
gui.Index.Screen.LEFT.Visible = false
gui.Index.Screen.RIGHT.Visible = false
gui.Index.Screen.MODE.Visible = true
gui.Index.Screen.Ammo.Text = ammo.Value.."/"..clip.Value
gui.BG:TweenPosition(UDim2.new(1, -325, 1, -125))
gui.Index:TweenPosition(UDim2.new(1, -310, 1, -110))
end
wait(1)
end
while true do
if armor.Value == "0" then
gui.Index2.Armor.Visible = false
gui.Index2.ARMOR.Visible = false
gui.BG:TweenPosition(UDim2.new(0, 0, 1, -75))
gui.Index:TweenPosition(UDim2.new(0, 20, 1, -60))
end
wait(1)
end
I tried it with the .changed but it didn't work
local plyr = script.Parent.Parent.Parent
local tool = plyr.Tool
local ammo = plyr.Tool.Ammo
local gui = script.Parent
local armor = plyr.Armor
local clip = plyr.Tool.Clip
while true do
if armor.Value == "0" then
gui.Index2.Armor.Visible = false
gui.Index2.ARMOR.Visible = false
gui.BG:TweenPosition(UDim2.new(0, 0, 1, -75))
gui.Index:TweenPosition(UDim2.new(0, 20, 1, -60))
end
wait(1)
end
armor.Changed:connect(function(NewValue)
if NewValue == "0" then
gui.Index2.Armor.Visible = false
gui.Index2.ARMOR.Visible = false
gui.BG:TweenPosition(UDim2.new(0, 0, 1, -75))
gui.Index:TweenPosition(UDim2.new(0, 20, 1, -60))
end
end)
tool.Changed:connect(function(NewValue)
if NewValue == "Test" then
gui.Index.Screen.Title.Text = "Test - ammothing"
gui.Index.Screen.Ammo.Visible = true
gui.Index.Screen.Ammo2.Visible = false
gui.Index.Screen.Controls.Visible = true
gui.Index.Screen.LEFT.Visible = false
gui.Index.Screen.RIGHT.Visible = false
gui.Index.Screen.MODE.Visible = true
gui.Index.Screen.Ammo.Text = ammo.Value.."/"..clip.Value
gui.BG:TweenPosition(UDim2.new(1, -325, 1, -125))
gui.Index:TweenPosition(UDim2.new(1, -310, 1, -110))
elseif NewValue == "Hands" then
gui.Index.Screen.Title.Text = "Hands - No Tool"
gui.Index.Screen.Ammo.Visible = false
gui.Index.Screen.Ammo2.Visible = false
gui.Index.Screen.Controls.Visible = false
gui.Index.Screen.LEFT.Visible = false
gui.Index.Screen.RIGHT.Visible = false
gui.Index.Screen.MODE.Visible = false
gui.BG:TweenPosition(UDim2.new(1, -325, 1, -75))
gui.Index:TweenPosition(UDim2.new(1, -310, 1, -60))
end
end)

5 comments
What type of script is this? What error, if any, are you getting? Why do you have two 'while true do' loops when the second one will never be reached?
its a localscript in a gui, idk why I have the second one, but now I know why that one doesn't work.
I suggest you look up the .changed event on the wiki. It'll keep your game from having to check the value every second.
ok, I will try it with .changed.
it didn't work, I will edit the question and post the new script