Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make pets file into a semi circle formation?

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!

3 comments

0

Include the full code

0

Thats what I have done, thats the code you need to know.

0

math.rad()

1 answer

✓ Accepted answer

This is a bit of modified code I got from the Roblox wiki

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

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)

* CFrame.new(0, 0, 180 / amount + offset)

wait()

  

end

1 comment

0

Well the thing is, if there are 2 pets then 1 pet is right behind and 1 pet is to the side, how I want it is that if there where 2 pets that 1 would be on the left side and the other on the right side.

This discussion is preserved as it was. New answers, comments, and votes are closed.