Door interaction system

So, I have this script to make the door open dependent on group rank. The door opens if you touch the part, I would like to know how to add Roblox’s interact system so that when you get close enough to the door, it brings up the hold e or tap screen to open the door. But only if you have the required rank. Is there a way to do this? If so, can you please edit my script and reply below?

Image:

4 Likes

You just add a proximity prompt and use the trigger event.

1 Like

The trigger event’s first parameter is the player.

Do you mind putting it into my script for me?

1 Like

Could you copy and paste it here so i can do it faster please?

local TweenService = game:GetService("TweenService")

local Players = game:GetService(“Players”)
local DoorPart = script.Parent
local OpenNoise = script.Parent.OpenNoise

local allowedRanks = {255, 254, 200, 199, 198, 197, 15, 14, 13, 5, 4, 3}

local OpenDoor = TweenService:Create(DoorPart, TweenInfo.new(2), {Position = Vector3.new(-112.474, 4.032, -172.335)})
local CloseDoor = TweenService:Create(DoorPart, TweenInfo.new(2), {Position = Vector3.new(-112.474, 4.032, -164.845)})
local CD = false

DoorPart.Touched:Connect(function(hit)
local player = Players:GetPlayerFromCharacter(hit.Parent)
if hit.Parent:FindFirstChild(“Humanoid”) and CD == false then
local rank = player:GetRankInGroup(9719071)
if table.find(allowedRanks, rank) then
CD = true
OpenNoise:Play()
OpenDoor:Play()
wait(3)
OpenNoise:Stop()
OpenNoise:Play()
CloseDoor:Play()
wait(3)
OpenNoise:Stop()
CD = false
end
end
end)

2 Likes
   local TweenService = game:GetService("TweenService")
local Players = game:GetService(“Players”)
 local DoorPart = script.Parent
  local OpenNoise = script.Parent.OpenNoise

local allowedRanks = {255, 254, 200, 199, 198, 197, 15, 14, 13, 5, 4, 3}

  local OpenDoor = TweenService:Create(DoorPart, TweenInfo.new(2), {Position = 
Vector3.new(-112.474, 4.032, -172.335)})
  local CloseDoor = TweenService:Create(DoorPart, TweenInfo.new(2), {Position = 
     Vector3.new(-112.474, 4.032, -164.845)})
      local CD = false

    DoorPart.ProximityPrompt.Triggered:Connect(function(player)
          if  CD == false then
      local rank = player:GetRankInGroup(9719071)
    if table.find(allowedRanks, rank) then
       CD = true
       OpenNoise:Play()
    OpenDoor:Play()
     wait(3)
      OpenNoise:Stop()
       OpenNoise:Play()
    CloseDoor:Play()
   wait(3)
   OpenNoise:Stop()
   CD = false
              end
       end
    end)

Just add a proximityprompt to the doorpart.

Also if you wanted it to only prompt ranked people then you could disable the prompts client sided.

I recommend using retractable doors, here’s some constraints you can use if you like:

Hinge Constraint
Spring Constraint

These stuff will create less lag but more efficient. (keep in mind you need to anchor the door if you want a rank door)

It’s easier then having to tween by the way. (IF your better at using constraints)

Edit: It’s only your option if you want to make a retracting door, you can find these on youtube: Making a Door: Vertical Hinge - YouTube , Making a Door: Closing with Springs - YouTube

That wouldn’t work since anchoring + constraints can end up in a disaster. Plus tweening is easier in this scenario.

Having the door anchored at all times would make it impossible to bug out.

Yeah, I found it as a disaster before as I tried making it. Soon it didn’t go very well as you might need to make a fix button for the door. (Edit: It’s my retractable door tbh.)

Is there a way to make the interact key invisible if they are lower than the required rank?

1 Like

Well the only way I could think of that is to change the enabled property to false client sided on all the lower ranks in game.

We can just set the dampening of the spring constraint to a very high amount instead, which produce the same effect as anchoring the door!

Thing is constraints can break but anchoring it will make it impossible to break.