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

How is shirt not a valid member of Player not working..?

Code :

script.Parent.MouseButton1Click:connect(function()
	
local plr = game.Players.LocalPlayer
local Shirt = "http://www.roblox.com/asset/?id=128133687"
local Pants = "http://www.roblox.com/asset/?id=128133700"

plr.Shirt = "http://www.roblox.com/asset/?id=128133687"
plr.Pants = "http://www.roblox.com/asset/?id=128133700"
end)

2 answers

To create an object you need to use Instance.new(object's class name, it's parent)

2 comments

0

What do you mean "It's parent" do you mind giving an example, for instance, a shirt.

0

Instance.new("Shirt",workspace.Player1)

The shirt and pants are part of the character model and not the player instance. In addition, you need to change the ShirtTemplate property of the shirt. This would like this:

script.Parent.MouseButton1Click:connect(function()
 
	local plr = game.Players.LocalPlayer
	local char = plr.Character or plr.CharacterAdded:wait()

	local Shirt = "http://www.roblox.com/asset/?id=128133687"
	local Pants = "http://www.roblox.com/asset/?id=128133700"
 	
	if char:FindFirstChild("Shirt") then
		char.Shirt.ShirtTemplate = Shirt
	else
		local newShirt = Instance.new("Shirt")
		newShirt.Parent = char
		newShirt.ShirtTemplate = Shirt
	end
	if char:FindFirstChild("Pants") then
		char.Pants.PantsTemplate = Pants
	else
		local newPants = Instance.new("Pants")
		newPants.Parent = char
		newPants.PantsTemplate = Pants
	end
end)

2 comments

0

This is not so efficient because if a player doesn't have a shirt or pants on, there won't be any shirt/pants in the character model.

0

I fixed it.

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