**So the background view is that ** I am trying to make an UI appear when a player gets close enough to an object, something like press E to Interact with an object something like Adopt Me.
The Script I have right now
local Folder = workspace.Folder
while wait(.25) do
local Table = {}
for i,v in pairs(Folder:GetChildren()) do
if LocalPlayer:DistanceFromCharacter(v.Position) <= 25 then
end
end
The problem
Its easy getting the closest part but Im trying to get the closest part to show something different so the closest part will be different and anything else will have the same UI's so I need to distinguish the closest part from all the parts that were found in that 25 stud radius.
To visualize it think of
{
ClosestPart = "Special GUI",
AnyPartInThe25StudRadius = {
--same UI
}
}
I will make a Special GUI popup for the closest part
the rest will have the same GUI popup
Right now all I can think of is using table.sort to do this
answer me if you have any better solutions

1 comment
Try proximity prompts. They're a new thing introduced by roblox, you can either use the default UI or a custom made one. I recommend looking at Proximity Prompt Service and more into proximity prompts. https://developer.roblox.com/en-us/articles/proximity-prompts