Lets say i want to make a game were everyone upon joing has a lets say for example a green shirt and green pants. how would i be able to do that
also sorry if the answer is obvious im a newbie to coding.
Lets say i want to make a game were everyone upon joing has a lets say for example a green shirt and green pants. how would i be able to do that
also sorry if the answer is obvious im a newbie to coding.
You would use the Event CharacterAdded as a trigger:
At the bottom of that article, there is an Accessory Remover example, which you could modify to do what you want.
In place of the for
loop, try
character.Pants.PantsTemplate = <the ID of the pants you want them to wear>
character.Shirt.ShirtTemplate = <the ID of the shirt you want them to wear>
1. local function onCharacterAdded(character)
character.Pants.PantsTemplate = <the ID of the pants you want them to wear>
character.Shirt.ShirtTemplate = <the ID of the shirt you want them to wear>
end
1. local function destroyshirts(object)
2. if object:IsA("Shirt") or object:IsA("Pants") then
3. object:Destroy()
4. end
I would launch the 2nd function first and the other function after
so kinda like that?
No like this
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
for _, thing in pairs(character:GetChildren()) do
if thing:IsA("Shirt") then
thing.ShirtTemplate = -- //Your ID of the shirt
end
if thing:IsA("Pants") then
thing.PantsTemplate = -- //Your ID of the pants
end
end
end)
end)
Oh ok thanks you thats helped alot