-
What do you want to achieve?
If the players rank is in the dictionary, and their rank is set to true then they are allowed to open the doors by holding e on them. -
What is the issue?
For some reason the door automatically closes, and sometimes randomly opens after being opened once.NOTE: I ALREADY TRIED WRITING THE TWEENINFO MANUALLY AND SETTING REVERSE TO FALSE
Video
Explorer
Code
--// VARIABLES \\--
local TweenService = game:GetService("TweenService")
local debounce = false
local isOpen = false
local door = script.Parent
local doorRoot = door.PrimaryPart
--// DICTIONARIES \\--
local DoorPermissions = {
['Guest'] = false,
['Experimental Asset'] = true,
['Priority: F'] = false,
['Priority: E'] = false,
['Priority: D'] = false,
['Priority: C'] = false,
['Priority: B'] = false,
['Priority: A'] = false,
['Corporate President'] = false,
['Chief Executive Officer'] = false,
['Corporate Chairman'] = false,
['Member'] = false,
['Admin'] = false,
['Owner'] = false,
['Agent'] = true,
['Special Agent'] = false,
['Special Agent In-Charge'] = false,
['Chief Agent'] = false,
['Director of Intelligence'] = false,
['Divisional Inspector'] = false,
['Oversight'] = false
}
--// TWEEN INFO \\--
local DoorSwingInfo = TweenInfo.new(1)
--// TWEEN GOALS \\--
local DoorSwingOpenGoal = {}
DoorSwingOpenGoal.CFrame = doorRoot.CFrame * CFrame.Angles(0, math.rad(85), 0)
local DoorSwingCloseGoal = {}
DoorSwingCloseGoal.CFrame = doorRoot.CFrame * CFrame.Angles(0, math.rad(0), 0)
--// CREATE TWEENS \\--
local DoorSwingOpenTween = TweenService:Create(doorRoot, DoorSwingInfo, DoorSwingOpenGoal)
local DoorSwingCloseTween = TweenService:Create(doorRoot, DoorSwingInfo, DoorSwingCloseGoal)
--// FUNCTIONS \\--
script.Parent.DoorPart.ProximityPrompt.Triggered:Connect(function(player)
local PlayersGroupRole = player:GetRoleInGroup(5910800)
local IntelligenceOfficeGroupRole = player:GetRoleInGroup(6200143)
local ExecutiveSecurityGroupRole = player:GetRoleInGroup(12152626)
for key, value in pairs(DoorPermissions) do
if key == PlayersGroupRole or key == IntelligenceOfficeGroupRole or key == ExecutiveSecurityGroupRole then
if value == true and debounce == false and isOpen == false then
debounce = true
isOpen = true
script.Parent.OpenSound.Playing = true
DoorSwingOpenTween:Play()
wait(2)
debounce = false
elseif value == true and debounce == false and isOpen == true then
debounce = true
isOpen = false
script.Parent.CloseSound.Playing = true
DoorSwingCloseTween:Play()
wait(2)
debounce = false
end
end
end
end)
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.