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

How would I make a wall that lets certain ranked people from a group through?

I wanted to make a wall that'd let only a certain rank go through.

This is what i've tried but idk how to define a group role:

script.Parent.Touched:Connect(function()
	
	if game.Players.LocalPlayer.Name == "UsernameHere" then
		
		script.Parent.CanCollide = false
		
	else
			
		script.Parent.CanCollide = true
	end
	
end)

1 comment

0

I changed my script. have a look

2 answers

✓ Accepted answer

Group ranks are ranged from 1-255, so what you need to do is check if the player's rank is bigger than or equal to the rank you want and then run the code.

You can do that through a function called GetRankInGroup which is a function of a player object.

Example:

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then -- check if what touched is a character
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)
		if player:GetRankInGroup(groupIdHere) >= 20 then -- replace 20 with rank number you want
			script.Parent.CanCollide = false
		else
			script.Parent.CanCollide = true
		end
	end
end)

Hope I helped, if you have any questions please let me know

7 comments

0

It doesnt appear to work, I put the group id and the rank number and it still wouldn't let me thorugh.

0

I am assuming this script is parented to the part that gets touched (the door)? And did you put this in a serverscript?

0

I put the script in the parent, and do you mean localscript? Or just a normal script?

0

Normal script, this should be in a normal script

0

Okay

0

It worked, thanks!

0

Happy to help :)

game.Players.PlayerAdded:Connect(function(player)
	-- just see if player is high enough rank 
	if player:GetRoleInGroup(group ID goes here) == ("Name of rank") then
		script.Parent.CanCollide = false
	else
		script.Parent.CanCollide = true
	end	
end)

1 comment

0

And what do I put in that "is high enough rank" string?

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