How could I get the character from player?

Hello! I’m trying to make a shirt changer, where you click on a part and it changes your shirt. Here is the current script: (local script)

game.Workspace.clothgivertest.ClickDetector.MouseClick:connect (function(plr)
	plr.Shirt.ShirtTemplate = 607785311
end)

However, I get the error:
Shirt is not a valid member of Player “Players.nicknickphoenix”
Would there be any way to get the character?

game.Workspace.clothgivertest.ClickDetector.MouseClick:connect (function(plr)
	plr.Character.Shirt.ShirtTemplate = 607785311
end)

You could use the Character property of a player

Also a few other things to note, connect is deprecated and shouldn’t be used in modern works, Connect is the newer version

Even then, I don’t think it would work either ways, if it doesn’t maybe try changing

plr.Character.Shirt.ShirtTemplate = 607785311

To

plr.Character.Shirt.ShirtTemplate = "rbxassetid://607785311"
4 Likes

Now i’m doing

game.Workspace.clothgivertest.ClickDetector.MouseClick:connect (function(plr)
	local character = plr.Character
	print(character)

	local charactermodel = game.Workspace.character
	charactermodel.Shirt = 607785311
	
	
end)

problem is, it’s trying to find game.Workspace.character, not the variable character. How would I fix this?

.Character already gives the Model, you don’t need

local charactermodel = game.Workspace.character

Your code shoudl look like this

game.Workspace.clothgivertest.ClickDetector.MouseClick:connect (function(plr)
	local character = plr.Character
	character.Shirt.ShirtTemplate = "rbxassetid://607785311"
end)
1 Like