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

GetRoleInGroup not working? [SOLVED]

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

✓ Accepted answer
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.

3 comments

0

Thanks for helping, unfortunately it's still not working. :( It gives an error on line 3: attempt to compare number with nil

0

Figured it out, just had to change your line 3 to GetRankInGroup! :) Thanks!

0

Sorry I couldnt change it before you seen the bug, but its hard to do that stuff on tablet.. >:/ But thanks for understanding.. :)

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