There are no errors. The goal is to change a hat based on several variables.
plr = game.Players.LocalPlayer char = plr.Character plrstats = script.Parent.Parent.PlayerStats hatval = plrstats.ActiveHat function onChanged(property) if property == hatval then if hatval.Value == "TempleSoldier1" then game.ReplicatedStorage.Hats.TempleSoldier1:clone().Parent = char elseif hatval.Value == "TempleSoldier2" then game.ReplicatedStorage.Hats.TempleSoldier2:clone().Parent = char elseif hatval.Value == "TempleSoldier3" then game.ReplicatedStorage.Hats.TempleSoldier3:clone().Parent = char end end end plr.Changed:connect(onChanged)
THANKS
Firstly, in line 08 you put "hatval" in "", instead of leaving it as hatval. Secondly, there are only 2 'end's, when there should be 3. Here is the corrected script, it should work now;
plr = game.Players.LocalPlayer char = plr.Character plrstats = script.Parent.Parent.PlayerStats hats = script.Parent.Parent.Hats hatval = plrstats.ActiveHat function onChanged(property) if property == hatval then if plr ~= nil and hatval.Value == "TempleSoldier1" then H = hats:findFirstChild(hatval.Value) H.Parent = char H.Position = char.Head.Position elseif plr ~= nil and hatval.Value == "TempleSoldier2" then H = hats:findFirstChild(hatval.Value) H.Parent = char H.Position = char.Head.Position elseif plr ~= nil and hatval.Value == "TempleSoldier3" then H = hats:findFirstChild(hatval.Value) H.Parent = char H.Position = char.Head.Position end end end plr.Changed:connect(onChanged)