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

I want player's shirt to be different but their old shirt stay on underneath?

Asked by
Zoltra 4
3 years ago

I want the player to wear a certain shirt. But it doesn't change it, it just puts it on top and the old shirt doesn't get removed. I don't understand how I'm supposed to remove it. I'm new to scripting and learning :p I appreciate the help

game.ReplicatedStorage.startShirt.OnServerEvent:Connect(function(plr)
    local char = plr.Character
    char:WaitForChild("Shirt").ShirtTemplate = game.ReplicatedStorage.Customisation.Shirts.sShirt1.ShirtTemplate
end)

If I try to remove it, then it stays in a WaitForChild loop and the new shirt doesn't come on. .-.

1 answer

Log in to vote
0
Answered by
Warphi 51
3 years ago
Edited 3 years ago

Hi! I think I can help with this, although I too am new to scripting so bear with me. You said that when you remove the shirt, your script is stuck in a waitforchild loop. In order to avoid this, try this:

game.ReplicatedStorage.startShirt.OnServerEvent:Connect(function(plr)
    local char = plr.Character
    char:WaitForChild("Shirt"):Destroy()
    local newshirt = game.ReplicatedStorage.Customisation.Shirts.sShirt1:Clone()
        newshirt.name = "Shirt"
        newshirt.Parent = char
end)

I hope this helps, if it does please remember to make it easier on other people trying to help and accept this answer. Comment with any questions :)

0
I'm getting 'name is not a valid member of Shirt' Zoltra 4 — 3y
0
That's odd, is sShirt1 a shirt object? Warphi 51 — 3y
0
Ok so it was because name wasn't capitalized. But it still doesn't work. The old shirt is still there Zoltra 4 — 3y
0
can you come into the community chat? should be on the top right of the page when you scroll all the way up. Warphi 51 — 3y
View all comments (2 more)
0
I'm such an idiot LOL. It's because I didn't remove pants yet, and these pants appear on the torso. LOLOLOL Thanks friend. If I remove pants it should work. Zoltra 4 — 3y
0
No problem, I'm glad I could help! Warphi 51 — 3y
Ad

Answer this question