A quick question regarding what things that would error return

Alright so Im just asking bc im not so sure. If I do something like:
local s = game.Players.royee354:GetRankInGroup(1) or 0
and thegetrankingroup fails due to an HTTP error, would it error or would s becomes 0

If game.Players.royee354:GetRankInGroup(1) is nil then s = 0. Check to make sure you have HTTPS Request enabled if don’t want s = 0

This might be due to attempting to find a invalid GroupID, you should probably check that the group you’re trying to search for is valid to the script you’re writing

For the OP, it more than likely would pass onto the next possible valid variable given since GetRankInGroup(1) would be returned back as nil

1 Like

You didn’t answer my question that is something I already know, the question is, if it fails would it return nil or error

It wouldn’t return nil or an error. It will return 0. Not sure what you mean, if it fails then s = 0.

Im talking about the getrankingroup function, lets say it will fail because of an HTTP issue, would the left side of the “or” be nil or would it just error and s wouldnt even be 0

So what happens is it checks the function if it does error then it would be nil, and since you have an or it would be 0. So s = 0 but if lets say after the or it was nil again I believe it will error.

Lets say you have two cars a red car or a blue car. You want to go in the red one but since that car doesn’t work you would go to the next available working car. There is probably a better analogy but hope this one helps.

I highly doubt there’s been a case where an HTTP error occurred on :GetRankInGroup(id) - it always returns an integer between 0 and 255. If they were not to be in group, the function would technically be false, with a number of 0 - if they were, then it’d technically return true, with a number above 1.

Funny thing, I actually tried this on a script & it doesn’t return back nil

It returns back 0 when printing it once, for proof use this script inside ServerScriptService:

game.Players.PlayerAdded:Connect(function(Player)
	local Rank = Player:GetRankInGroup(1938592358234823)
	print(Rank)
	
	if not Rank then
		Rank = 0
		print(Rank)
	end
	
end)