Need Help For Fixinig My Script

I need help for fixing this script it didn’t clone clothing to my character and nothing error on output it just work 5 sec after i joining the game,after 5 sec it didn’t clone it

--[[ Local ]]--
local manager = script.Customize.Manager

local maskmanager = manager.Mask
local shirtmanager = manager.Shirt
local pantsmanager = manager.Pants

--[[ Function ]]--
function ClothesManager(character)
	if not character:FindFirstChildOfClass("Accessory") then 
		maskmanager:Clone().Parent = character
	else character:FindFirstChildOfClass("Accessory"):Destroy()
		maskmanager:Clone().Parent = character
	end
	
	if not character:FindFirstChild("Shirt") then 
		shirtmanager:Clone().Parent = character
	else character:FindFirstChild("Shirt"):Destroy()
		shirtmanager:Clone().Parent = character
	end

	if not character:FindFirstChild("Pants") then 
		pantsmanager:Clone().Parent = character
	else character:FindFirstChild("Pants"):Destroy()
		pantsmanager:Clone().Parent = character
	end
end

game.Players.PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function(char)
		local plr = game.Players:FindFirstChild(char.Name)

		while true do
			if plr.Status.Role.Value ~= "Manager" then 
				ClothesManager(char)
			else
				return
			end
		end
	end)
end)

Do the accessory’s have Handle’s inside of it with a weld?

yes all the accessory has weld

but accessory,shirt and pants didnt clone after 5 sec it just clone when i change role before 5 sec

Then I don’t understand the problem it should work, it’s waiting till the player joins the game and upon doing so calling the ClothesManager function to clone and parent the accessory in the character.

I’m still not following by what you mean, the objects didn’t clone after 5 seconds and it just cloned when you changed the role? What role and what are you doing to have it wait for 5 seconds to not have it work, elaborate more so I can help you.

Wait first of all, you’re setting this in a clientscript therefore making it visually impossible for the server to see what you’re wearing you can only see that on the client, I suggest putting it on the server.

it already server side but it just work when i change the role fast like joining the game then i change role it work but if i joining and afk then i change role it didnt work

Oh that’s prolly bc you’re using game.Players.PlayerAdded, that checks when the player has been added to the server, if you wait anylonger than after the Player has been added to the server then it’ll not work.

instead do the Changed event, check when the value is changed then if it has call the function above.

plr.Status.Role.Changed:Connect(function(v)
  if v ~= "Manager" then
      ClothesManager(char)
  else
    return
end