Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make pets file into a semi circle formation?

Asked by 5 years ago

Please include the code which you are trying to use, so the community will be better-equipped to help you with your problem.

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!

0
Include the full code User#24403 69 — 5y
0
Thats what I have done, thats the code you need to know. outlook1234567890 115 — 5y
0
math.rad() greatneil80 2647 — 5y

1 answer

Log in to vote
0
Answered by
xEmmalyx 285 Moderation Voter
5 years ago
Edited 5 years ago

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 thislua 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 ```

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. outlook1234567890 115 — 5y
Ad

Answer this question