Help with this rank id door

That is a good reason of why it wouldn’t work but as far as I know, this would might work, but in the instance that it doesn’t the person using the script could freely amend.

So, I’m able to put this script onto a regular script page and place it under the part and it’ll work just fine?

Yes, It should and just connect the instances in the script with the door and try amending the script to your likings.

Script was a failure, I don’t know if it was in my behalf but I’m pretty sure it is. I’ll have to look into what’s wrong now.

The problem is :GetRankInGroup() requires a group id to function, the original script was correct.

Just minor suggestions:

1- local player = game:GetService("Players").LocalPlayer

2- local door = workspace:WaitForChild("StaffDoor")

Small correction:
A LocalScript will only run Lua code if it is a descendant of one of the following objects:

  • A Player’s Backpack, such as a child of a Tool
  • A Player’s character model
  • A Player’s PlayerGui
  • A Player’s PlayerScripts.
  • The ReplicatedFirst service

I would recommend replacing it with a serverscript, as that would be the safest approach as the server should handle the checking.

Your script most like don’t work because it’s not a descendant of the following:

  • A Player’s Backpack, such as a child of a Tool
  • A Player’s character model
  • A Player’s PlayerGui
  • A Player’s PlayerScripts.
  • The ReplicatedFirst service

Here’s an example (including a Touched event, as that will fire onc ethe player touches the door):

local Players = game:GetService('Players')
local Door = game:GetService('Workspace').Door

local GroupId = 00000
local Min = 150
local Time = 5

local Debounces = {}


local function Touched
(Hit)
	local Player = Players:GetPlayerFromCharacter(Hit.Parent)
	if (Player)
	then
		local Check = Player:GetRankInGroup(GroupId)
		if (Check >= Min)
		then
			if (table.find(Debounces, Player.UserId))
			then return end
			table.insert(Debounces, Player.UserId)
			Door.CanCollide = false
			wait(Time)
			Door.CanCollide = true
			table.remove(Debounces, table.find(Debounces, Player.UserId))
		end	
	end
end


Door.Touched:Connect(Touched)
1 Like