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

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

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

✓ Accepted answer

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 :)

6 comments

0

I'm getting 'name is not a valid member of Shirt'

0

That's odd, is sShirt1 a shirt object?

0

Ok so it was because name wasn't capitalized. But it still doesn't work. The old shirt is still there

0

can you come into the community chat? should be on the top right of the page when you scroll all the way up.

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.

0

No problem, I'm glad I could help!

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