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

Why is plr.CharacterAdded:connect(function(char) Not working???

This is a script I composed to change any character that joins the game's clothing:

plr.CharacterAdded:connect(function(char)
	player.Pants.PantsTemplate = 182807730
	player.Shirt.ShirtTemplate = 182807618
end)

Basically, when I try to run this, my character's clothing flashes grey (loading the texture I assume) then going to what my character is set to look like. (Not what the PantsTemplate / ShirtTemplate is set to in the script) What am I doing wrong

3 comments

1

can you post the full script.

0

Is this a script or a localscript?

0

It is a regular script, does it need to be a local script?

1 answer

This isn't anywhere near a full script.

How do you get plr? Where is it defined? It isn't. Along with that, the Pants and Shirt are in the character, not the player, which again you don't define.

To get the player I suggest the PlayerAdded function.

-- Regular Script in ServerScriptService
--// Services
local Players = game:GetService("Players")

--\\ Code
Players.PlayerAdded:Connect(function(plr)

end)

Cool! Now we have the player; let's get the character. We can get the character with the CharacterAdded event.

-- Regular Script in ServerScriptService
--// Services
local Players = game:GetService("Players")

--\\ Code
Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)

	end)
end)

Now we should be able to add your code:

-- Regular Script in ServerScriptService
--// Services
local Players = game:GetService("Players")

--\\ Code
Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		char:WaitForChild("Pants").PantsTemplate = 182807731
		char:WaitForChild("Shirt").ShirtTemplate = 182807619
	end)
end)

2 comments

0

It's not working

0

Probably has to do with the PantsTemplate and stuff. Might need to be a string.

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