Difference Between == and >=

So, I have a script that gives tools to certain ranks. Although, if you are ABOVE that rank, it gives you the tool anyway. I only want certain ranks given a certain tool.

local tool = game.ServerStorage['[SCP] Card-L1']
function onPlayerSpawned(player)
	if player:IsIngroup(groupId) then 
		tool:Clone().Parent = player.Backpack
	end
end

game.Players.PlayerAdded:connect(function(player)
  player.CharacterAdded:connect(function()
    onPlayerSpawned(player)
  end)
end)

function onPlayerSpawned(player)
  if player:GetRankInGroup(groupId) == 4 then
    tool:Clone().Parent = player.Backpack
  end
end

So, the == 4 part does not work. Basically, I want to give the tool to just 4, not anything higher. I made it >= and it worked, but it gave all tools to the higher ranks. Can anybody help?

Given your information it seems like 4 is not the right value for the rank you are referring to.

It is. I want the tool given to the 4th rank.

Can you double check on your group if there exists a role with the 4th rank, also test it in the actual game and not in studio.

I have many scripts like this, I have the 4th, 5th, 6th, ect. None of them give the tools. I’ve been testing in game this whole time.

can you debug to see if the event is fired.

function onPlayerSpawned(player)
  if player:GetRankInGroup(groupId) == 4 then
    print("Check")
     tool:Clone().Parent = player.Backpack
  end
end

(Just to double check that the event is firing)
1 Like

The roles in a group are assigned numbers between 1 and 255, with 255 being the owner and 0 being a non-member. Rank does not mean the number by which they are listed on the web page.

You can check the rank on the Configure Group page:

1 Like

I understand. I just have it by number order.

Another possibility: The account you’re testing with doesn’t have the role with the 4th rank,

Check if your rank is 4.

Nope, it doesn’t have that.{30 chars}

1 Like

Are you trying to give the tool to the 4th rank starting at the bottom or top?

Your code should work if you put the right rank.

1 Like

The operator ==, in English, means “is it equal to.”
The operator >= means “is it greater than OR equal to.”

Okay, like most others have said it is most likely there is no 4 rank in your group.
As an alternative you can use the GetRoleInGroup() function and instead of having the # you can say if player:GetRoleInGroup(groupid) == "ROLE NAME" then...

2 Likes

Is this a localscript or serverscript?

It should be a serverscript, because with a local script you can just do

local player = game.Players.LocalPlayer

While in a serverscript you have to do

game.Players.PlayerAdded:Connect(function(player)
    --code
end)