Help needed with GUI appearing in a certain area. (Magnitude)

Hi, so I’m trying to make an open button for my game its pretty simple to make it, however I need help with it appearing in a certain area (Magnitude). Also, not a billboard GUI. Any suggestions? Thanks.

local frame = script.Parent
local open = frame:WaitForChild("Open")

open.MouseButton1Click:Connect(function()
	open.Visible = false
	frame.Visible = false
end)

I’m not sure if I’m understanding the question, judging by the code you provided. The code you’ve given is clicking, not detecting if a player is in a certain area.

You could check if a player is near a part through magnitude by doing something like:

local Player = game.Players.LocalPlayer --//assuming it's local, if not, then don't use that
local Character = Player.Character or Player.CharacterAdded:Wait()
local Root = Character:WaitForChild("HumanoidRootPart")
local Part = game.Workspace:WaitForChild("TargetPart") --// change this to your part you want to see if the player is close to
local Distance = (Root.Position - Part.Position).Magnitude

if Distance < 5 then
--// Player is within area (5 can be changed to accommodate different distances), show UI
...
2 Likes

To help you clarify on what magnitude is(@Polyheximal already gave you the answer, if he understangs the question).

Magnitude is basically the amount of studs or pixels(pixels only for ui) something is apart of.