Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.
Put this script in the door
01 | local distanceGUIOpens = 10 |
02 | game.Players.PlayerAdded:connect( function (plr) |
03 | repeat wait() until plr.Character |
04 | if (plr.Character.Torso.Position-script.Parent.Position).Magnitude< = distanceGUIOpens then |
05 | if not plr.PlayerGui:FindFirstChild( "DoorGui" ) then |
06 | local gui = Instance.new( "ScreenGui" ) |
07 | local textbox = Instance.new( "TextBox" ) |
08 | gui.Parent = plr.PlayerGui |
10 | textbox.Name = "DoorGui" |
11 | textbox.Text = 'Press "E" to open door' |
13 | textbox.BackgroundTransparency = 1 |
14 | textbox.Position = UDim 2. new( 0.5 , 0 , 0.2 , 0 ) |
16 | if (plr.Character.Torso.Positionscript.Parent.Position).Magnitude> = distanceGUIOpens then |
This script should work