Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I fix this Auto Uniform Script?

Asked by 10 years ago

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
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. BlackJPI 2658 — 10y
0
I have changed the char in both lines to c, but to no prevail. FaultyMatrix 30 — 10y
0
May you print an output please RM0d 305 — 10y
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 FaultyMatrix 30 — 10y
0
I moved the script to another world and I don't get any errors. Just no uniform. FaultyMatrix 30 — 10y

1 answer

Log in to vote
2
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
10 years ago

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
0
I have placed this into my game, but again, I'm still not getting a uniform. FaultyMatrix 30 — 10y
0
How have you tried testing? What have you tested? What output does this script produce? BlueTaslem 18071 — 10y
Ad

Answer this question