Here’s my code :
local inputservice = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
inputservice.InputBegan:connect(function(i,g)
if i.UserInputType == Enum.UserInputType.Keyboard then
if i.KeyCode == Enum.KeyCode.E then
for _,Door in pairs(workspace.Door["Large Doors"]:GetChildren()) do
for _,Door2 in pairs(Door:GetChildren()) do
for _,Door3 in pairs(Door2:GetChildren()) do
--Main issue is here
if mouse.Target and mouse.Target.Name == "Door" then
local Mag = (Door3.Center.Position-game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart").Position).magnitude
if Mag <= Door3.Range.Value then
Door3.Event:FireServer()
break
end
end
end
end
end
end
end
end)
(This isn’t all the code. I just provided all the code and pictures that are the problem. I also tested my doors without all the other code and it worked the same just with or without the GUI)
Its hard to explain, but basically I find if my mouse is over the the doors part then I go to
magnitude to find if I’m close enough to active the door. However I ran into some issues…
I have no idea what I should do about this, any help is appreciated!