How do I make this door script E to open while facing the door? [closed]
I've been working at this for a while and haven't come up with a solution. This door script teleport the player to a part and i am trying to make it E to open but only making the GUI pop up while the mouse is facing the door and now i'm back to square one.
I Would really love some help. Thank you in advance
01 | local plr = game.Players.LocalPlayer |
03 | local teleports = workspace:WaitForChild( "Teleports" ) |
04 | local enterButton = script.Parent.enterButton |
09 | enterButton.MouseButton 1 Click:connect( function () |
13 | local hrp = plr.Character:FindFirstChild( "HumanoidRootPart" ) |
17 | hrp.CFrame = exitPart.CFrame + Vector 3. new( 0 , 3 , 0 ) |
22 | game:GetService( "RunService" ).RenderStepped:connect( function () |
24 | for _,door in pairs (teleports:GetChildren()) do |
26 | if door.Name:sub( 0 , 4 ) = = "Door" then |
28 | local exit = teleports:FindFirstChild( "Exit" ..door.Name:sub( 5 )) |
30 | local hrp = plr.Character:FindFirstChild( "HumanoidRootPart" ) |
34 | if (door.Position-hrp.Position).magnitude < range then |
36 | if not enterButton.Visible then |
37 | enterButton.Visible = true |
43 | if enterButton.Visible then enterButton.Visible = false end |