Problem with pet placement

local CurrentPets = {}

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local RS = game:GetService("RunService")
local UIS = game:GetService("UserInputService")

local Template = Instance.new("Part")
Template.Size = Vector3.new(2,2,2)
Template.Anchored = true
Template.CanCollide = false

UIS.InputBegan:Connect(function(key,proc)
	if not proc then
		if key.KeyCode == Enum.KeyCode.Y then
			local Pet = Template:Clone()
			Pet.Parent = workspace
			table.insert(CurrentPets,Pet)
		end
	end
end)
RS.RenderStepped:Connect(function()
	local Deg = (math.pi*2)/#CurrentPets
	local SubI = 1
	for i,v in pairs(CurrentPets) do
		if SubI > 3 then
			SubI = 1
		end
		local Row = math.floor(i/3)
		local CF = Character.PrimaryPart.CFrame * CFrame.new(-6 + (3*SubI),0,(3*Row)+3)
		v.CFrame = v.CFrame:Lerp(CF,0.1)
		SubI += 1
	end
end)

Here’s the problem:


For some reason the third pet goes back

local Row = math.ceil(i/3)
1 Like

Thanks, that worked. Don’t really know the difference though.

math.floor rounds down a value

math.floor(1.2) -- 1
math.floor(1.9) -- 1
math.floor(2.5) -- 2

math.ceil rounds… you guess it! up!

math.ceil(1.2) -- 2
math.ceil(1.9) -- 2
math.ceil(2.5) -- 3

I don’t know what difference this would have in my script though.