This is my codes:
local Ghosts = workspace.Ghosts:GetChildren() -- this is a folder.
for i=1,#Ghosts - 1 do
local Ghost
local Distance = Player:DistanceFromCharacter(Ghosts[i].PrimaryPart.Position)
local NextDistance = Player:DistanceFromCharacter(Ghosts[i+1].PrimaryPart.Position)
if Distance < NextDistance then
Ghost = Ghosts[i]
else
Ghost = Ghosts[i+1]
end
end
My code only can get two ghosts :C
Does there the better way to change this?
I want make it can get two or up.
Thanks for answering!
