So currently I am making a pet system where the pets you have follow you around in a semi circle formation behind you, however this is not working very well.
Here is the code that decides the offset from the humanoidrootpart and ultimately the semi circle formation.
local val = ((#v.Tab/2)*-1) if i ~= 1 then val = val + 2 end print(val) local offset = Vector2.new(-5,val)
i is (for i,x in pairs())
Any help would be greatly appreciated!
This is a bit of modified code I got from the Roblox wiki ```lua local amount = 25 -- amount of parts local offset = 15 -- how far apart they are local startCFrame = CFrame.new(0, 25, 0) -- where the semi-circle will form
for angle = 1, amount do
local p = Instance.new('Part', workspace) p.Size = Vector3.new(1, 1, 1) p.Anchored = true p.CanCollide = false p.CFrame = startCFrame * CFrame.Angles(0, (180 / amount) * math.rad(angle), 0) * CFrame.new(0, 0, offset) wait()
end
If I were to try to implement this in your script it'd likely look something like this
lua
local offset = 10 -- units offset from eachother
local startCFrame = game.Players[PlayerName].Character.HumanoidRootPart.CFrame -- where the semi-circle will form
for i,x in pairs(workspace.Pets[PlayerName]:GetChildren()) do
local amount = #workspace.Pets[PlayerName]:GetChildren()
x.Anchored = true
x.CFrame = startCFrame * CFrame.Angles(0, math.rad(-90) + ((180 / amount) * math.rad(i)), 0)
wait()
end ```