I've attempted to create a auto uniform script. It doesn't seem to want to work for some reason. Would anyone be able to fix this for me please?
print("Uniform Script Loaded Sucessfully!!") local baseurl = "http://www.roblox.com/asset/?id=" local clothingData = {{rank = 1, shirt = 137338539, pants = 154082705}, {rank = 2, shirt = 137338539, pants = 137338545}, {rank = 3, shirt = 137338539, pants = 137338545}, {rank = 4, shirt = 137338539, pants = 137338545}, {rank = 5, shirt = 137338539, pants = 137338545}, {rank = 6, shirt = 137338539, pants = 137338545}, {rank = 7, shirt = 144851570, pants = 144939229}, {rank = 8, shirt = 144851570, pants = 144939229}, {rank = 100, shirt = 144851553, pants = 144939305}, {rank = 150, shirt = 144851553, pants = 144939305}, {rank = 151, shirt = 144938162, pants = 144937798}, {rank = 170, shirt = 144938162, pants = 144937798}, {rank = 249, shirt = 144943553, pants = 156726468}, {rank = 250, shirt = 144943553, pants = 156726468}, {rank = 251, shirt = 144850883, pants = 156726468}, {rank = 252, shirt = 144850883, pants = 156726468}, {rank = 253, shirt = 144850883, pants = 156726468}, {rank = 254, shirt = 144850883, pants = 156726468}} function newPlayer(p) if p:IsInGroup(869857) then p.CharacterAdded:connect(function(c) if not char:FindFirstChild("Pants") then Instance.new("Pants", c).Name = "Pants" end if not char:FindFirstChild("Shirt") then Instance.new("Shirt", c).Name = "Shirt" end local rank = p:GetRankInGroup(869857) for i=1, #clothingData do if v.rank == rank then c.Shirt.ShirtTemplate = baseurl .. v.shirt c.Pants.PantsTemplate = baseurl .. v.pants end end end) end end game.Players.PlayerAdded:connect(newPlayer) for _,v in pairs (game.Players:GetPlayers()) do newPlayer(v) end
1st, like MastaJames said, you need to either pick char
or c
since you're using both but only defined c
(the parameter of the function).
Later, you forgot to define v
in your iteration (v = clothingData[i]
)
At this point, I believe your script is working, except that, just like your loop to guarantee newPlayer
is fired for players already in the place, you have to do the same thing for CharacterAdded
or else this will only work after dieing once:
print("Uniform Script Loaded Sucessfully!!") local baseurl = "http://www.roblox.com/asset/?id=" local clothingData = {{rank = 1, shirt = 137338539, pants = 154082705}, {rank = 2, shirt = 137338539, pants = 137338545}, {rank = 3, shirt = 137338539, pants = 137338545}, {rank = 4, shirt = 137338539, pants = 137338545}, {rank = 5, shirt = 137338539, pants = 137338545}, {rank = 6, shirt = 137338539, pants = 137338545}, {rank = 7, shirt = 144851570, pants = 144939229}, {rank = 8, shirt = 144851570, pants = 144939229}, {rank = 100, shirt = 144851553, pants = 144939305}, {rank = 150, shirt = 144851553, pants = 144939305}, {rank = 151, shirt = 144938162, pants = 144937798}, {rank = 170, shirt = 144938162, pants = 144937798}, {rank = 249, shirt = 144943553, pants = 156726468}, {rank = 250, shirt = 144943553, pants = 156726468}, {rank = 251, shirt = 144850883, pants = 156726468}, {rank = 252, shirt = 144850883, pants = 156726468}, {rank = 253, shirt = 144850883, pants = 156726468}, {rank = 254, shirt = 144850883, pants = 156726468}} function clothePlayer(c,p) if not char:FindFirstChild("Pants") then Instance.new("Pants", c).Name = "Pants" end if not char:FindFirstChild("Shirt") then Instance.new("Shirt", c).Name = "Shirt" end local rank = p:GetRankInGroup(869857) for i=1, #clothingData do local v = clothingData[i]; if v.rank == rank then c.Shirt.ShirtTemplate = baseurl .. v.shirt c.Pants.PantsTemplate = baseurl .. v.pants end end end function newPlayer(p) if p:IsInGroup(869857) then p.CharacterAdded:connect( function(c) clothePlayer(c,p) end ); if p.Character then clothePlayer(p.Character,p); end end end game.Players.PlayerAdded:connect(newPlayer) for _,v in pairs (game.Players:GetPlayers()) do newPlayer(v) end