local minimum = 3
local groupID = 6792809
local authorized = false
local Player = game.Players.LocalPlayer
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local Door = game.Workspace.Kitchen_Door
local DoorPart = Door.Door
local DoorPrimaryPart = Door.PrimaryPart
local NearDoor = false
if game.Players.LocalPlayer:GetRankInGroup(groupID) >= minimum then
authorized = true
end
RunService.RenderStepped:Connect(function()
if Player:DistanceFromCharacter(DoorPrimaryPart.Position) < 5 then
NearDoor = true
DoorPrimaryPart.EToOpen.Enabled = true
else
NearDoor = false
DoorPrimaryPart.EToOpen.Enabled = false
end
end)
UserInputService.InputBegan:Connect(function(Input)
if Input.UserInputType == Enum.UserInputType.Keyboard then
local Key = Input.KeyCode
if Key == Enum.KeyCode.E and NearDoor == true and authorized == true then
Door.Beep:Play()
DoorPart.CanCollide = false
wait(5)
DoorPart.CanCollide = true
end
end
end)
local minimum = 3
local groupID = 6792809
local authorized = false
local Player = game.Players.LocalPlayer
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local Door = game.Workspace.Kitchen_Door
local DoorPart = Door.Door
local DoorPrimaryPart = Door.PrimaryPart
local NearDoor = false
if game.Players.LocalPlayer:GetRankInGroup(groupID) >= minimum then
authorized = true
else
return
end
RunService.RenderStepped:Connect(function()
if Player:DistanceFromCharacter(DoorPrimaryPart.Position) < 5 then
NearDoor = true
DoorPrimaryPart.EToOpen.Enabled = true
else
NearDoor = false
DoorPrimaryPart.EToOpen.Enabled = false
end
end)
UserInputService.InputBegan:Connect(function(Input)
if Input.UserInputType == Enum.UserInputType.Keyboard then
local Key = Input.KeyCode
if Key == Enum.KeyCode.E and NearDoor == true and authorized == true then
Door.Beep:Play()
DoorPart.CanCollide = false
wait(5)
DoorPart.CanCollide = true
end
end
end)
local minimum = 3
local groupID = 6792809
local authorized = false
local Player = game.Players.LocalPlayer
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local Door = game.Workspace.Kitchen_Door
local DoorPart = Door.Door
local DoorPrimaryPart = Door.PrimaryPart
local NearDoor = false
if game.Players.LocalPlayer:GetRankInGroup(groupID) >= minimum then
authorized = true
else
return
end
RunService.RenderStepped:Connect(function()
if (Player.Character.Head.Position - Door.Position).Magnitude < 5 then
NearDoor = true
DoorPrimaryPart.EToOpen.Enabled = true
else
NearDoor = false
DoorPrimaryPart.EToOpen.Enabled = false
end
end)
UserInputService.InputBegan:Connect(function(Input)
if Input.UserInputType == Enum.UserInputType.Keyboard then
local Key = Input.KeyCode
if Key == Enum.KeyCode.E and NearDoor == true and authorized == true then
Door.Beep:Play()
DoorPart.CanCollide = false
wait(5)
DoorPart.CanCollide = true
end
end
end)
The problem here, is that your door’s primary part is nil, you didn’t set it. Go to your door model and set the primary part, then it won’t be nil and that should work. The primary part is in the door’s properties.
Also, make sure that this is the right path to the door, because if it isn’t, then the door is nil too, and that’s why the primary part is not detected (if it exists)