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

Why won't this onclick clothes giver work?

local Pants = script.Pants
local Shirt = script.Shirt

local GroupID = 6763603 -- Group id here

script.Parent.ClickDetector.MouseClick:connect(function(Player)
    if not Player:IsInGroup(GroupID) then return end
    if Player:GetRoleInGroup(GroupID) < 50 then return end
    local Character = Player.Character
    if Character == nil then return end

    -- Get new shirt
    local CharacterShirt = Character:findFirstChild("Shirt")
    if CharacterShirt then CharacterShirt:Destroy() end
    Shirt:Clone().Parent = Character

    -- Get new pants
    local CharacterPants = Character:findFirstChild("Pants")
    if CharacterPants then CharacterPants:Destroy() end
    Pants:Clone().Parent = Character
end)

In the output it say's "Workspace.Part.Script:8: attempt to compare string and number"

1 answer

✓ Accepted answer

The reason why your script won't work is actually very simple, by doing Player:GetRoleInGroup it would print out the name of the role they have in the group, if you wanted to get the number corresponding to their role, you would do :GetRankInGroup. If you take this into account, the script would look like this.

local Pants = script.Pants
local Shirt = script.Shirt

local GroupID = 6763603 -- Group id here

script.Parent.ClickDetector.MouseClick:connect(function(Player)
    if not Player:IsInGroup(GroupID) then return end
    if Player:GetRankInGroup(GroupID) < 50 then return end
    local Character = Player.Character
    if Character == nil then return end

    -- Get new shirt
    local CharacterShirt = Character:findFirstChild("Shirt")
    if CharacterShirt then CharacterShirt:Destroy() end
    Shirt:Clone().Parent = Character

    -- Get new pants
    local CharacterPants = Character:findFirstChild("Pants")
    if CharacterPants then CharacterPants:Destroy() end
    Pants:Clone().Parent = Character
end)

2 comments

0

Thank's alot this solved my problem, but any clue how to add more than role id?

0

If you could help that would be nice :)

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