Pet Position System

  1. What do you want to achieve? Keep it simple and clear! I am trying to position a pet to be behind the player.

  2. What is the issue? Include screenshots / videos if possible! Whenever it hatches the pet’s cframe is not changed or set

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub? I looked at multiple solutions on developer hub but they didn’t work

My current script:

    local PetM = _G.PetInfo
    local Attachment0 = hum.RootRigAttachment
    local Attachment1 ='Attachment')
    local Constraint ='WeldConstraint')
	local PosN ='NumberValue')
	PosN.Parent = pet.PrimaryPart
	PosN.Value = petPos
	PosN.Name = 'PetPos'
	Constraint.Parent = pet.PrimaryPart
	Attachment1.Parent = pet.PrimaryPart
	Constraint.Part0 = hum
	Constraint.Part1 = pet.PrimaryPart
	pet.PrimaryPart.CFrame = hum.CFrame
	--pet.PrimaryPart.Position +=,5,0)
	for i,part in pairs(pet:GetDescendants()) do
		if part:IsA('Part') or part:IsA('MeshPart') then
			part.CanCollide = false
			part.Position +=,3.5,0)
			--part.Orientation +=,-90,0)

			--part.Position = part.Position - (part.CFrame.LookVector *,0,0))
			--part.Position = part.Position +,0,(-3 + ((petPos - 1) * 3)))
	player:WaitForChild('PetForce').Value += PetM[pet.Name].Power
	player:WaitForChild('Slots')[petPos].Value = true
	player.leaderstats:WaitForChild('JumpPower').Value = (player:WaitForChild('PetForce').Value + player:WaitForChild('DefaultForce').Value)

The pet spawns way behind the player where it was made


but works when you reset


if you can tell me why this is happening that would be really helpful

I’m not entirely sure but it could be the player was not found as the script plays instantly

Well it is because I walk over and hatch the egg

I was reading your script and you used Position. You should use CFrame.

Maybe something like this:

pet.PrimaryPart.CFrame = hum.CFrame * Offset

Offset is how much you want to move it. Using a CFrame.

Hope this helps.

Never mind I realised that it set the constraint before the position so just switching them around solved it

Thanks for everyone’s help