I'm currently working on an infection type game and I need help changing the face on the playermodel once you get switched to the infected team.
local faceId = "http://www.roblox.com/asset/?id=501885626" game.Players.PlayerAdded:Connect(function(player) player.Changed:Connect(function(att) if att == "Team" then local char = player.Character or player.CharacterAdded:Wait() local head = player:WaitForChild("Head") local decal = head:WaitForChild("face") local desc = game.Players:CreateHumanoidModelFromUserId(player.UserId) local normalFace = desc.Face desc:Destroy() if player.Team == game.Teams.Infected then decal.Texture = faceId elseif player.Team == game.Teams.Survivors then decal.Texture = normalFace end end end) end)
This is the code I have so far. Whenever I am testing and switch to the infected team it outputs Infinite yield possible on 'Players.jackcough62689:WaitForChild("Head")' Any help would be greatly appreciated.
This is bc the code is constantly waiting for the head in the player, where there is none, so it will infinetely wait. Just switch out the player to char. Change line 8 to
local head = char:WaitForChild("Head")