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 :

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

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:

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)

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