Help with an open Ui pad

I need help with my pad. I want to have a pad that opens a shop gui. I am using Touched and TouchEnded. Idk if it is the most efficent way to make something like this so thats why im asking for better, more efficient ways to do so.

Video Reference

Any help will be great

Well you could try to use magnitude.

1 Like

Well what is magnitute and how does it work?

You can look it up, but basically magnitude is a way to determine distance.

1 Like

You can use Magnitude like this:

Local RunService = game:GetService("RunService")
RunService.RenderStepped:Connect(function()
if (Character.HumanoidRootPart.Position - ShopPart.Position).Magnitude <= 4 then
--Open
else
--Close
end
end)
1 Like

I agree with this, TouchEnded legit never works the way you want it. Another option is Region3 (sorry if spellt wrong) but Magnitude is more simple enough for starters.

2 Likes

How would i get the character? without Touched/TouchEnded

It can be a local script and you can use

local Player = game.Players.LocalScript
1 Like

I use to get the Character like this:

local player = game:GetService("Players").LocalPlayer or game.Players.PlayerAdded:Wait()
local Character = player.Character or player.CharacterAdded:Wait()
2 Likes

Thanks so much for the help. Really appreciate it!

1 Like

Just don’t make it close automatically. Use an exit button (A big X).