This is a simple question.
I'm actually trying to figure out how can anyone make some interactive doors, things or anything.
Some Examples: - When close to a door, it shows: Press E to Open. - When close to a game item, it shows: Press T to Obtain.
Thanks for answering! :D
Nice day or night!
Use magnitude
Example:
local player = game.Players.LocalPlayer local char = player.Character if (char.Torso.Position - workspace.Door.Position).magnitude >=5 then player.PlayerGui.ScreenGui.Frame.Visible = true end
To make the door open after this GUI is shown, simply use
UserInputService
And whenever the key to open the door (let's say E), then check if the Frame is visible, and if it is, you can then create your own things.
I'll teach you how this service works, so you know next time, it helps a lot.
We'll start by obtaining this service
.
local UIS = game:GetService("UserInputService") function onKeyPress(key) if key.KeyCode == Enum.KeyCode.E and player.PlayerGui.ScreenGui.Frame.Visible == true then OpenDoor() -- Link to the open door function, which has your own code to open the door. end end UIS.InputBegan:connect(onKeyPress)
Create your own OpenDoor function
like this:
function OpenDoor() -- code to open door here end -- or local OpenDoor = function() -- code to open door here end
Hope I helped! If you are confused about ANYTHING regarding GUI's, UserInputService, I will be more than happy to provide links or information.
Also PLEASE accept my answer, if it helped you, or if it was right.