Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do I make this door script E to open while facing the door? [closed]

Asked by 4 years ago

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

local plr = game.Players.LocalPlayer

local teleports = workspace:WaitForChild("Teleports")
local enterButton = script.Parent.enterButton

local range = 5
local exitPart

enterButton.MouseButton1Click:connect(function()

    if exitPart then

        local hrp = plr.Character:FindFirstChild("HumanoidRootPart")

        if hrp then 

            hrp.CFrame = exitPart.CFrame + Vector3.new(0,3,0)
        end
    end
end)

game:GetService("RunService").RenderStepped:connect(function()

    for _,door in pairs(teleports:GetChildren()) do

        if door.Name:sub(0,4) == "Door" then 

            local exit = teleports:FindFirstChild("Exit"..door.Name:sub(5))

            local hrp = plr.Character:FindFirstChild("HumanoidRootPart")

            if hrp then 

                if (door.Position-hrp.Position).magnitude < range  then

                    if not enterButton.Visible then
                        enterButton.Visible = true

                    end

                else

                    if enterButton.Visible then enterButton.Visible = false end
                    exitPart = exit
                end
            end
        end
    end
end)
0
You want open the door when the client click on the keycode E on the keyboard? NiniBlackJackQc 1562 — 4y

Closed as Not Constructive by hiimgoodpack and raid6n

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?