So yeah.The error is in the title as well but "Attempt to index nil with Position". Im not too good at magnitude but I'm developing my scripting skills.
local debounce = false
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
local uis = game:GetService("UserInputService")
local char = plr.Character:FindFirstChild("HumanoidRootPart")
local dis = 15
uis.InputBegan:Connect(function(Input)
local key = Input.KeyCode
if key == Enum.KeyCode.E then
if mouse.Target.Name == "Door" then
if debounce == false then
if (char.Position - mouse.Target.Position).Magnitude < dis then
if mouse.Target.Value.Value == false then
mouse.Target.Value.Value = true
mouse.Target.Transparency = 1
elseif mouse.Target.Value.Value == true then
mouse.Target.Value.Value = false
mouse.Target.Transparency = 0
end
end
end
end
end
end)

1 comment
Worked.Thank you very much.I will accept your answer.