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

GetRoleInGroup not working? [SOLVED]

Asked by 9 years ago

EDIT Just had to change GetRoleInGroup to GetRankInGroup. ^^

Hello ScriptingHelpers.

I just created a script to see that it is not working. My script is supposed to give a taser and a railgun to the people in the required roll in the group which is 12 and above. These are the trainers.

When I run the script, I get this error on line 4:- attempt to compare number with string

Here is the script:- ( Ps, not sure if the green bits are true. I wrote them as accurately as possible. )

game.Players.PlayerAdded:connect(function(p) -- Sees if a player joins.
p.CharacterAdded:connect(function() -- When the character is added.
        RN = p:GetRoleInGroup(1240173) -- Sees if the player is in the group.
        if RN >= 12 then -- If the player is in the roll 12 or above (trainer).
            game.ServerStorage.Taser:Clone().Parent = p.Backpack -- Gives tools.
            game.ServerStorage.Railgun:Clone().Parent = p.Backpack -- Gives tools.
        end
    end)
end)

Thanks if you helped! :]

1 answer

Log in to vote
2
Answered by 9 years ago
game.Players.PlayerAdded:connect(function(p)
p.CharacterAdded:connect(function() 
        if tonumber(p:GetRankInGroup(1240173))  >= 12 then -- Convert the string (If there is a function sting) to a number.
            game.ServerStorage.Taser:Clone().Parent = p.Backpack 
            game.ServerStorage.Railgun:Clone().Parent = p.Backpack 
        end
    end)
end)

Im sorry is this errors Im on tablet right now.. :/ Also if it does error message me ASAP and I will fix it.

0
Thanks for helping, unfortunately it's still not working. :( It gives an error on line 3: attempt to compare number with nil WelpNathan 307 — 9y
0
Figured it out, just had to change your line 3 to GetRankInGroup! :) Thanks! WelpNathan 307 — 9y
0
Sorry I couldnt change it before you seen the bug, but its hard to do that stuff on tablet.. >:/ But thanks for understanding.. :) MessorAdmin 598 — 9y
Ad

Answer this question