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

How do I fix this Auto Uniform Script?

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

5 comments

1

You called the variable 'char' on lines 25 and 28 when it is non-existent. You declared the variable 'c' in the CharacterAdded function, so that is the variable you should use.

0

I have changed the char in both lines to c, but to no prevail.

0

May you print an output please

0

Uniform Script Loaded Sucessfully!! Loaded gloo library. Type _G.gloo.Help() for help. zars15's CFrame loaded 21:58:51.937 - Successfully opened file - C:/Documents and Settings/New User/AppData/Local/Roblox/visit.rbxl logging probability 0.064180425428022 not logging 21:58:52.484 - Attempt to connect failed: Passed value is not a function 21:58:52.484 - Script 'Players.Player1.Backpack.Musket.Sho

0

I moved the script to another world and I don't get any errors. Just no uniform.

1 answer

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

2 comments

0

I have placed this into my game, but again, I'm still not getting a uniform.

0

How have you tried testing? What have you tested? What output does this script produce?

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