Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 7 years ago

Code :

1script.Parent.MouseButton1Click:connect(function()
2 
3local plr = game.Players.LocalPlayer
6 
9end)

2 answers

Log in to vote
0
Answered by 7 years ago

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

0
What do you mean "It's parent" do you mind giving an example, for instance, a shirt. devconstruct 4 — 7y
0
Instance.new("Shirt",workspace.Player1) Mayk728 855 — 7y
Ad
Log in to vote
0
Answered by
RayCurse 1518 Moderation Voter
7 years ago
Edited 7 years ago

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:

01script.Parent.MouseButton1Click:connect(function()
02 
03    local plr = game.Players.LocalPlayer
04    local char = plr.Character or plr.CharacterAdded:wait()
05 
08 
09    if char:FindFirstChild("Shirt") then
10        char.Shirt.ShirtTemplate = Shirt
11    else
12        local newShirt = Instance.new("Shirt")
13        newShirt.Parent = char
14        newShirt.ShirtTemplate = Shirt
15    end
View all 23 lines...
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. Mayk728 855 — 7y
0
I fixed it. RayCurse 1518 — 7y

Answer this question