Click to Open Rank Door

Hello, there! I am currently working on a door that would open when clicked by a player with a certain rank in my group. However, I am having some troubles as my doors consist of multiple parts which causes issues.

My current script:


local TweenService = game:GetService("TweenService")
local Players = game:GetService("Players")

local hinge = script.Parent.Doorframe.Hinge
local click_detector = script.Parent.Base.ClickDetector

local goal_open = {}
goal_open.CFrame = hinge.CFrame * CFrame.Angles(0, math.rad(90), 0)

local goal_close = {}
goal_close.CFrame = hinge.CFrame * CFrame.Angles(0, 0, 0)

local tween_info = TweenInfo.new(1)

local tween_open = TweenService:Create(hinge, tween_info, goal_open)
local tween_close = TweenService:Create(hinge, tween_info, goal_close)

local open = false
local group = 34215674
local rank = 200

click_detector.MouseClick:Connect(function(player)
	if Players:GetPlayerFromCharacter(player.Character) then
		local player_real = Players:GetPlayerFromCharacter(player.Character)
		if player_real:GetRankInGroup(group) >= rank then
			if open then
				open = false
				tween_close:Play()
			else
				open = true
				tween_open:Play()
			end
		else
			player.Character:MoveTo(Vector3.new(script.Parent.NoPermissions.Position))
		end
	end
end)

script.Parent.Detector.Touched:Connect(function(hit, player)
	if not hit.Parent:FindFirstChildOfClass("Humanoid") then return end
	if Players:GetPlayerFromCharacter(hit.Parent) then
		local player_real = Players:GetPlayerFromCharacter(hit.Parent)
		if player_real:GetRankInGroup(group) >= rank then
			return
		else
			hit.Parent:MoveTo(Vector3.new(script.Parent.NoPermissions.Position))
		end
	end
end)```
2 Likes

Is the issue that the tweens arent working? Or that all the parts in the door arent moving?

If its the ladder then what I would recommend is welding all your parts in each door to a single part that acts as the hinge for the door, and then unanchored all of these parts except the hinge.

If its a different problem please specify

1 Like

Thanks, it still doesn’t seem to work though.

1 Like

What exactly are the issues though? Could you provide a video of what’s happening?

1 Like

robloxapp-20241220-1512074.wmv (872.6 KB)

robloxapp-20241220-1513214.wmv (427.2 KB)

Trying to make it like in the first video, and then the second video is what I have currently.

1 Like

K couple questions, first off when you use the click detector and do MouseClick why do you try and get the Player from player.Character, you already have the player, so there isnt much point to doing it,

Reference:

after that what I would recommend is put prints every where inside of your functions, one to check when the MouseClick function is triggered, one that prints the rank of the player, one that prints when the tweens play, this way we can check to see if they are running to begin with

2 Likes