I've been trying to fix this issue, but cannot seem to find a fix. Here is the code below:
local Player = game.Players.LocalPlayer:FindFirstChild("Humanoid")
local RunService = game:GetService("RunService")
local UIS = game:GetService("UserInputService")
local Door = game.Workspace.DualDoorsE.SecondaryDoorE2
local DoorPrimaryPart = Door.PrimaryDoorPart
local NearDoor = false
RunService.RenderStepped:Connect(function()
if (Player.Position - DoorPrimaryPart.Position).magnitude < 5 then
NearDoor = true
DoorPrimaryPart.EToOpen.Enabled = true
else
NearDoor = false
DoorPrimaryPart.EToOpen.Enabled = false
end
end)
UIS.InputBegan:Connect(function(Input)
if Input.UserInputType == Enum.UserInputType.Keyboard then
local Key = Input.KeyCode
if Key == Enum.KeyCode.E and NearDoor == true then
Door.ToggleDoor:FireServer()
end
end
end)
According to the output, this is the line that triggers the error:
if (Player.Position - DoorPrimaryPart.Position).magnitude < 5 then
Can someone figure out why that occurs? I would really appreciate the help.

1 comment
On Line 6, you forgot to close the bracket.