Group Rank Seat Not Working

I’m pretty new at scripting but I’m trying to making a group seat that only accepts the minimum and maximum rank, plus another rank that’s allowed to sit on it. It’s currently not working and acts like a normal seat.

Output Error:
00:37:02.828 Workspace.TechRoomPC.Sofa.Seat.Group Only Seat:8: attempt to compare number and boolean - Server - Group Only Seat:8

GroupID = 9392267
min = 101
max = 255
accept = 12

script.Parent.ChildAdded:connect(function(child)
	if child.Name == "SeatWeld" then 
		if not game.Players:GetPlayerFromCharacter(child.Part1.Parent):GetRankInGroup(GroupID) >= min and
			game.Players:GetPlayerFromCharacter(child.Part1.Parent):GetRankInGroup(GroupID) <= max and
			game.Players:GetPlayerFromCharacter(child.Part1.Parent):GetRankInGroup(GroupID) == accept then
			wait(0.00001)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              --Looking for me? :D
			child:Destroy()
			child.Part1.Parent.Humanoid.Jump = true
        end
	end
end)
1 Like

Try this.

GroupID = 9392267
min = 11
max = 254
accept = 12

script.Parent.ChildAdded:connect(function(child)
	if child.Name == "SeatWeld" then 
		local Player = game.Players:GetPlayerFromCharacter(child.Part1.Parent)
		if Player then
			if not Player:GetRankInGroup(GroupID) >= min and Player:GetRankInGroup(GroupID) <= max and Player:GetRankInGroup(GroupID) == accept then
				repeat wait(0.5) child.Part1.Parent.Humanoid.Jump = true until child.Parent == nil 
			end
		end	
	end
end)

Sorry, it still says the same output and doesn’t work

Screenshot of the console please.

you’re repeating a lot of stuff in that if statement and the reason it doesn’t work is because not happens before comparison so it returns a boolean (true/false), then you compare boolean and number which results in an error. Also, try defining some variables to avoid calling the same functions multiple times:

GroupID = 9392267
min = 11
max = 254
accept = 12

script.Parent.ChildAdded:connect(function(child)
	if child.Name == "SeatWeld" then
		local plr = game.Players:GetPlayerFromCharacter(child.Part1.Parent)
		local rank = plr:GetRankInGroup(GroupID)
		if rank ~= min or rank ~= max or rank ~= accept then  -- Not sure if this is the behavior you wanted but at least it shouldn't error
			wait(0.00001)
			child:Destroy()
			child.Part1.Parent.Humanoid.Jump = true
		end
	end
end)

Studio1

So you want the accepted RankId to only access the seat?

I want Min to Max to be accepted but so does the Allowed rank.

For example, I want the high ranks with the to be able to sit on it, but also a certain rank.

Hi! It works but now, it won’t allow me to sit

So you want “[LR] Actor” and above to access the chair?

Oh sorry, I wrote that wrong, I want [MR] Supervisor and above to access the chair. But also [LR] Technical Crew

There is only the rank “[MR] Supervisor” in your group.

That’s what I meant, sorry lol

local GroupData = {
	GroupId = 9392267,
	Min = 101,
	Accepted = 12
}

function CheckAccess(Player)
	if Player:GetRankInGroup(GroupData.GroupId) == GroupData.Accepted then return true end
	if Player:GetRankInGroup(GroupData.GroupId) >= GroupData.Min then return true end
	return false
end

script.Parent.ChildAdded:connect(function(child)
	if child.Name == "SeatWeld" then 
		local Player = game.Players:GetPlayerFromCharacter(child.Part1.Parent)
		if Player then
			if CheckAccess(Player) then
				repeat wait(0.5) child.Part1.Parent.Humanoid.Jump = true until child.Parent == nil 
			end
		end	
	end
end)

Round 2, Try this.

Edit: It it set to Anyone above [MR] Supervisor can access it and then anyone with the rank [LR] Technical Crew will have access

1 Like

alrighty, I’ve fixed the if statement

GroupID = 9392267
min = 101
max = 254
accept = 12

script.Parent.ChildAdded:connect(function(child)
	if child.Name == "SeatWeld" then
		local plr = game.Players:GetPlayerFromCharacter(child.Part1.Parent)
		local rank = plr:GetRankInGroup(GroupID)
		if rank < min and rank ~= accept then
			wait(0.00001)
			child:Destroy()
			child.Part1.Parent.Humanoid.Jump = true
		end
	end
end)
1 Like

Thank you so much, It works, I just had to change all the True to false, and false to true

if Player:GetRankInGroup(GroupData.GroupId) == GroupData.Accepted then return false end
	if Player:GetRankInGroup(GroupData.GroupId) >= GroupData.Min then return false end
	return true
1 Like