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

How do i set a group role only hat?

I want to make it so when you touch the part, and you have that specific role in your group, it will give you the hat. Error: Workspace.Part.Script:9: attempt to compare number and string

local hat = game.ServerStorage.or3
local groupid = 4911373 
local door = script.Parent 
door.Touched:connect(function(part)
    local plr =  game.Players:GetPlayerFromCharacter(part.Parent)
    if plr then
        if plr:IsInGroup(groupid) then
            if plr:GetRoleInGroup(4911373)  >= 100 then     
                script.Parent.Touched:Connect(function(hit)
                    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
                    if player then
                        if not hit.Parent:FindFirstChild("hat") then
                            hat:Clone().Parent = hit.Parent
                        end
                    end
                end)
            end
        end
    end
end)

1 comment

0

Why do you have the 2 same touched events? Remove the event inside and I think it should be fixed.

1 answer

✓ Accepted answer
if plr:GetRoleInGroup(4911373)  >= 100 then 

This returns the role name not the role number. You should change it to:

if plr:GetRankInGroup(4911373) >= 100 then

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