local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
local deb = false
local gui = plr.PlayerGui.Interact.Background
local dis = 5
local function doorAction()
local door = mouse.Target
mouse.Target.actionScript.Disabled = false
mouse.Target.canInteract.Parent = game.ReplicatedStorage
wait(4)
mouse.Target.actionScript.Disabled = true
game.ReplicatedStorage.canInteract.Parent = door
end
local function onKeyDown( key )
if key == "e" then
if deb == false then deb = true
print("You just interacted with a "..mouse.Target.canInteract.Value)
if mouse.Target.canInteract.Value == "door" then
doorAction()
end
end
end
end
while true do wait()
if mouse.Target then
if mouse.Target:FindFirstChild("canInteract") then
local mag = (plr.Character.Torso.Position - mouse.Hit.p).Magnitude
if mag<=dis then
gui.Visible = true
mouse.KeyDown:connect(onKeyDown)
deb = false
else
gui.Visible = false
end
else
gui.Visible = false
end
end
end
When I click the first door the second door opens. Idk why
