Having multiple 'pets' at once?

I’d just change the entire script to this

function renderDuck(ducks)
	local RotationOffset = 360/#ducks
	
	for _, v in pairs(ducks) do
		local PlayersDuck = Ducks['Tier ' .. v.Tier][v.Rarity]:Clone()
		PlayersDuck.Name = v.Tier .. ' - ' .. v.Rarity
		PlayersDuck.Parent = Character
		
		local Duck = PlayersDuck.Duck
		
		local bp = Instance.new('BodyPosition')
		local bg = Instance.new('BodyGyro')
				
		bg.D = 750
		bg.MaxTorque = Vector3.new(25000, 25000, 25000)
		bg.P = 5000
		
		bp.D = 400
		bp.MaxForce = Vector3.new(1250, 10000, 1250)
		bp.P = 2000
					
		bg.Parent = Duck
		bp.Parent = Duck
	
		Duck.Position = HumanoidRootPart.Position + Vector3.new(0, 10, 0)
		follow(v, GetPointOnCircle(5, RotationOffset*_), bg, bp)
	end
end

Can you elaborate on what ducks is?

3 Likes
function follow(Pet, Pos, bg, bp)
	spawn(function()
		RunService.RenderStepped:Connect(function()		
			bg.CFrame = HumanoidRootPart.CFrame
			bp.Position = (HumanoidRootPart.CFrame * CFrame.new(Pos)).p - Vector3.new(0, HumanoidRootPart.Size.Y / 2, 0) + Vector3.new(0, Pet.Size.Y, 0)
			wait()
		end)
	end)
end

function renderDuck(ducks)
	local RotationOffset = 360/#ducks
	
	for _, v in pairs(ducks) do
		local PlayersDuck = Ducks['Tier ' .. v.Tier][v.Rarity]:Clone()
		PlayersDuck.Name = v.Tier .. ' - ' .. v.Rarity
		PlayersDuck.Parent = Character
		
		local Duck = PlayersDuck.Duck
		
		local bp = Instance.new('BodyPosition')
		local bg = Instance.new('BodyGyro')
				
		bg.D = 750
		bg.MaxTorque = Vector3.new(25000, 25000, 25000)
		bg.P = 5000
		
		bp.D = 400
		bp.MaxForce = Vector3.new(1250, 10000, 1250)
		bp.P = 2000
					
		bg.Parent = Duck
		bp.Parent = Duck
	
		Duck.Position = HumanoidRootPart.Position + Vector3.new(0, 10, 0)
		follow(Duck, GetPointOnCircle(5, RotationOffset*#ducks), bg, bp)
	end
end

Ok, ducks is

CurrentDucks = {
		[1] = {Tier = 1, Rarity = 'Common'},
		[2] = {Tier = 1, Rarity = 'Uncommon'},
		[3] = {Tier = 2, Rarity = 'Rare'},
	},

That’s what gets sent, so 3 spots, for 3 ducks basically

Still didnt work tho :confused: no error, all 3 inside each other

2 Likes

This line is probably causing your problems of moving one far away

Duck.Position = HumanoidRootPart.Position + Vector3.new(0, 10, 0)

This line here is probably causing your problems of them being inside one another

follow(Duck, GetPointOnCircle(5, RotationOffset*#ducks), bg, bp)

This is probably happening because multiplying RotationOffset (which you previously calculated to be 360/#ducks) by #ducks is just saying 360, or 0


Here’s what I made your code

function renderDuck(ducks)
	local RotationOffset = 360/#ducks
	
	for i, v in pairs(ducks) do
		local PlayersDuck = Ducks['Tier ' .. v.Tier][v.Rarity]:Clone()
		PlayersDuck.Name = v.Tier .. ' - ' .. v.Rarity
		PlayersDuck.Parent = Character
		
		local Duck = PlayersDuck.Duck
		
		local bp = Instance.new('BodyPosition')
		local bg = Instance.new('BodyGyro')
				
		bg.D = 750
		bg.MaxTorque = Vector3.new(25000, 25000, 25000)
		bg.P = 5000
		
		bp.D = 400
		bp.MaxForce = Vector3.new(1250, 10000, 1250)
		bp.P = 2000
					
		bg.Parent = Duck
		bp.Parent = Duck
	
		--Duck.Position = HumanoidRootPart.Position + Vector3.new(0, 10, 0)
		follow(Duck, GetPointOnCircle(5, RotationOffset*i), bg, bp)
	end
end
4 Likes


Still all inside each other

1 Like

Make sure that your GetPointOnCircle function is this

local function GetPointOnCircle(CircleRadius, Degrees)
	return Vector3.new(math.cos(math.rad(Degrees)) * CircleRadius, 0, math.sin(math.rad(Degrees)) * CircleRadius)
end

Try printing the return value to see if it’s any different each time (something like this)

local function GetPointOnCircle(CircleRadius, Degrees)
    print(CircleRadius, Degrees)
	return Vector3.new(math.cos(math.rad(Degrees)) * CircleRadius, 0, math.sin(math.rad(Degrees)) * CircleRadius)
end

edit: It’s all fixed, we did it in DMs. See Having multiple 'pets' at once? - #24 by OverHash for the solution to the problem

5 Likes

Don’t forget to mark the reply that fixed your problem as the solution.

2 Likes

Hey, Overhash.
I know this is over 1 year later, but I was wondering, if you know, how i’d get the circle to start in the back of my player, and not on the side, since it kinda triggers my ocd, that one side has more pets, than the other, when you have an uneven amount of pets. I’d like it to start in the back of my character, so that if the amount is uneven, the front will have more pets.

So, do you have any idea, how I’d change the starting point or just overall rotation of this circle?

Thanks.

Well the entire reason the pets circle around your character in the first place is because you’re positioning them around your HumanoidRootPart I assume. So just position it a little ways away from the Humanoid Root Part

1 Like