Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why does this CharacterAppearance only works in Solo mode?

game.Players.PlayerAdded:connect(function(p)
	wait(1)
for i, v in ipairs(game.Players:GetChildren())do
	v.Character.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=179631998"
	v.Character.Pants.PantsTemplate = "http://www.roblox.com/asset/?id=179650451"
	end
	
end)

-- Its a script in Workspace and it seems to work in solo mode, but doesn't in- game. Please help!

2 comments

0

Please help, it only works in solo :(

0

Change "wait(1)" to "repeat wait() until p.Character

1 answer

I've fiddled with the code a bit and made some improvements.

For whatever reason Start Server doesn't give the players a pants or shirt object so I added some code to fix that.

Version 1: This will give the player the shirt and pants when they join the game.

game.Players.PlayerAdded:connect(function(p)
	repeat wait() until p.Character -- Wait for a character
	local char = p.Character
	if not char:FindFirstChild("Shirt") then -- If they don't have a shirt object give them one
		Instance.new("Shirt",char).Name = "Shirt"
	end
	if not char:FindFirstChild("Pants") then -- If they don't have a pants object give them one
		Instance.new("Pants",char).Name = "Pants"
	end
	char:WaitForChild("Shirt").ShirtTemplate = "http://www.roblox.com/asset/?id=179631998"
	char:WaitForChild("Pants").PantsTemplate = "http://www.roblox.com/asset/?id=179650451"
end)

Version 2: This will give the player the shirt and pants every time they respawn and when they join the game

game.Players.PlayerAdded:connect(function(p)
 	p.CharacterAdded:connect(function(char)
		repeat wait() until p.Character -- Wait for a character
		local char = p.Character
		if not char:FindFirstChild("Shirt") then -- If they don't have a shirt object give them one
			Instance.new("Shirt",char).Name = "Shirt"
		end
		if not char:FindFirstChild("Pants") then -- If they don't have a pants object give them one
			Instance.new("Pants",char).Name = "Pants"
		end
		char:WaitForChild("Shirt").ShirtTemplate = "http://www.roblox.com/asset/?id=179631998"
		char:WaitForChild("Pants").PantsTemplate = "http://www.roblox.com/asset/?id=179650451"
	end)
end)

2 comments

0

still doesn't work, only works in solo

0

I think I fixed it

This discussion is preserved as it was. New answers, comments, and votes are closed.