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)

1 comment
You want open the door when the client click on the keycode E on the keyboard?