Hi, i need help with one thing, i’m already maked a pet grid system , that sets pets positions like in PSX or other games where multiple pets follow player, but i don’t know how to update pets position after removing one (unequipping for example), can someone help me and explain how to do this?
i figured that myself ```local folder = script.Parent
local PetsFolder = folder.Pets
local template = folder.Pet
local Player = folder.Player
local Count = folder.Count
local collumn = 5
local startPos = Player.Position + Vector3.new(2,0,2)
local spacing = 4
local function OnRemove()
wait(0)
for i, p in pairs(PetsFolder:GetChildren()) do
if p and p:IsA("BasePart") then
i-= 1
local x = i%collumn
local z = math.floor(i/collumn)
local newpos = startPos + Vector3.new(-x*spacing,0,z*spacing)
p.Position = newpos
end
if i == #PetsFolder:GetChildren() then
break
end
end
end
local function OnAdded(object:BasePart)
for i = 0, #PetsFolder:GetChildren()-1 do
local x = i % collumn
local z = math.floor(i/collumn)
local newPos = startPos + Vector3.new(-x*spacing,0,z*spacing)
object.Position = newPos
object.Parent.ChildRemoved:Connect(function(obj)
OnRemove()
end)
if i == #PetsFolder:GetChildren()-1 then
break
end
end