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

This script isn't working, can anyone help? It involves clothing and group ranks/id's

GiveClothes = function(char)
    for i,v in pairs(char:children()) do
        if v:IsA("Clothing") then
            v:Destroy()
        end
    end
    script.Pants:Clone().Parent = char
    script.Shirt:Clone().Parent = char
end

GroupId = 0
RanksThatGetClothing = {"Private"}

game.Players.PlayerAdded:connect(function(plr)
    plr.CharacterAdded:connect(function(char)
        local allowed = false
        for i,v in pairs(RanksThatGetClothing) do
            if v:GetRoleInGroup(GroupId) == v then
                allowed = true
            end
        end
        if allowed then
            GiveClothes(char)
        end
    end)
end)

3 comments

0

Change v:GetRoleInGroup(GroupId) to plr:GetRoleInGroup(GroupId)

0

Does the :children and :connect need changing like it says below?

0

I got it working! Thank you so much!!!

3 answers

First off: Change all of the :connect to :Connect Put it all in a code block so I can see everything else

GiveClothes = function(char)
    for i,v in pairs(char:children()) do
        if v:IsA("Clothing") then
            v:Destroy()
        end
    end
    script.Pants:Clone().Parent = char
    script.Shirt:Clone().Parent = char
end

GroupId = 0
RanksThatGetClothing = {"Private"}

game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)
        local allowed = false
        for i,v in pairs(RanksThatGetClothing) do
            if v:GetRoleInGroup(GroupId) == v then
                allowed = true
            end
        end
        if allowed then
            GiveClothes(char)
        end
    end)
end)

3 comments

0

The Pants and Shirt ID isn't the same as the Product ID. For example, if the ID for the pants on the catalog is 78690501, in the script, it wouldn't be the same number. Go on catalog, and subtract 1 from the ID number. Keep doing that until you find the product that has the same name as your pants, but the picture looks different. That is the ID you need. Also, use :GetChildren(), not :children.

0

I know that there is a pants and shirt object inside the script

0

And that didn't fix it anyway :/

maybe because you left the group id to 0 ://////////////////////////

1 comment

0

Still doesn't work

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