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

My Uniform script wont work after respawning?

so i made a script to give rank members some cloths for my game and i came across that it wont work on re spawning, here is my script

shirt="http://www.roblox.com/asset/?id=2711023361"
pants="http://www.roblox.com/asset/?id=2711025542"

game.Players.PlayerAdded:connect(function(player)
if player:GetRankInGroup(6081502) == 255 then
for i,v in pairs(player.Character:GetChildren()) do
if v:IsA("Shirt") then
v.ShirtTemplate=shirt
elseif v:IsA("Pants") then
v.PantsTemplate=pants
else
s=Instance.new("Shirt",player.Character)
p=Instance.new("Pants",player.Character)
s.ShirtTemplate=shirt
p.PantsTemplate=pants
end
end
end
end)

1 answer

✓ Accepted answer

You need to use the character added function. It triggers every time the character loads in.

shirt="http://www.roblox.com/asset/?id=2711023361"
pants="http://www.roblox.com/asset/?id=2711025542" --Whenever you retexture this remember to subtract 1 from the number.

game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:Connect(function(char)
if player:GetRankInGroup(6081502) == 255 then
for i,v in pairs(player.Character:GetChildren()) do
if v:IsA("Shirt") then
v.ShirtTemplate=shirt
elseif v:IsA("Pants") then
v.PantsTemplate=pants
else
s=Instance.new("Shirt",player.Character)
p=Instance.new("Pants",player.Character)
s.ShirtTemplate=shirt
p.PantsTemplate=pants
end
end
end
end)
end)

Mark as the answer if this works.

2 comments

0

most mods would add a note saying "Explain this answer"

0

Ok I will.

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