Get Planetname on FindinSphere

Hey Guys

You all know the jedi vs sith maps and im gonna do something special for my HUD

I need the planet name on my hud

I have the variable: planet

and if im on one planet i have the vector coordinates from the center of the planet

and if im in this sphere the variable planet = “Endor” filled with text Endor

if im on another Planet the variable planet = “Othername”

but how i can make this check if the LocalPlayer():GetPos on FindinSphere from planet endor do this

will work?

Which functions i need to use (not the whole code just the functions i gonna need for it)

thanks a lot

You could store a table with inside your planets, for each row their name, center and size:
planets = {
{name = “Mars”, position = Vector(12, 34, 56)},

Then with

Vector:Distance, get the closest planet to the player’s

Entity:GetPos and show its name.

local closest, dist
for _, p in pairs (planets) do
local d = LocalPlayer():GetPos():Distance(p.position)
if (!closest or dist > d) then
dist = d
closest = p


Note that this gets the planet closest to the player, but doesn’t check if the player is actually inside that planet! You’ll need to modify your code to make sure the player is within the planet’s radius or something, ideally with the Distance function I provided you.

(untested but you should get the gist)