So, I made a script in which it gives uniforms to the teams, and a hat. The uniforms clothing shirts and pants show up and work fine, but the hats don't show up. I placed a hat object into Lighting then I placed the model of the hat as it's child. How can I fix the problem in which the hat doesn't show up?
local team1 = game.Teams:findFirstChild("Germans") local team2 = game.Teams:findFirstChild("U.S. Army") -- put the team name, not color local t1shirt = game.Lighting:findFirstChild("RedShirt") local t2shirt = game.Lighting:findFirstChild("GreenShirt") local t1hat = game.Lighting:findFirstChild("RedHat") local t2hat = game.Lighting:findFirstChild("GreenHat") local t1pants = game.Lighting:findFirstChild("RedPants") local t2pants = game.Lighting:findFirstChild("GreenPants") --put the clothes and pants in lighting and put their name there function onSpawn(player) wait(1) -- takes time for the clothes to load local clothing = player.Character:GetChildren() for i = 1, #clothing do -- my favorite line in scripting, this is so uesful in everything if clothing[i].className == "Pants" or clothing[i].className == "Shirt" or clothing[i].className == "Hat" then clothing[i]:remove() -- removes the clothes of course end end if player.TeamColor == team1.TeamColor then t1shirt:Clone().Parent = player.Character t1pants:Clone().Parent = player.Character t1hat:Clone().Parent = player.Character -- puts uniforms into the person end if player.TeamColor == team2.TeamColor then t2shirt:Clone().Parent = player.Character t2pants:Clone().Parent = player.Character t2hat:Clone().Parent = player.Character end end function A(new) -- this function connects the player to the function above whenever the person respawns new.Changed:connect(function(N) if N == "Character" then onSpawn(new) end end) end game.Players.ChildAdded:connect(A)
local team1 = game.Teams:findFirstChild("Germans") local team2 = game.Teams:findFirstChild("U.S. Army") -- put the team name, not color local t1shirt = game.Lighting:findFirstChild("RedShirt") local t2shirt = game.Lighting:findFirstChild("GreenShirt") local t1hat = game.Lighting:findFirstChild("RedHat") local t2hat = game.Lighting:findFirstChild("GreenHat") local t1pants = game.Lighting:findFirstChild("RedPants") local t2pants = game.Lighting:findFirstChild("GreenPants") --put the clothes and pants in lighting and put their name there function onSpawn(player) wait(1) -- takes time for the clothes to load local clothing = player.Character:GetChildren() for i = 1, #clothing do -- my favorite line in scripting, this is so uesful in everything if clothing[i].className == "Pants" or clothing[i].className == "Shirt" or clothing[i].className == "Hat" then clothing[i]:remove() -- removes the clothes of course end end if player.TeamColor == team1.TeamColor then t1shirt:Clone().Parent = player.Character t1pants:Clone().Parent = player.Character local clone = t1hat:Clone() local w = Instance.new("Weld") w.Part0 = clone:FindFistChild("PART") -- "PART" should be the center of the hat. w.Part1 = player.Character.Head w.Parent = player.Character.Head clone.Parent = player.Character end if player.TeamColor == team2.TeamColor then t2shirt:Clone().Parent = player.Character t2pants:Clone().Parent = player.Character local clone = t2hat:Clone() local w = Instance.new("Weld") w.Part0 = clone:FindFistChild("PART") -- "PART" should be the center of the hat. w.Part1 = player.Character.Head w.Parent = player.Character.Head clone.Parent = player.Character end end function A(new) -- this function connects the player to the function above whenever the person respawns new.Changed:connect(function(N) if N == "Character" then onSpawn(new) end end) end game.Players.ChildAdded:connect(A)