So I have made a quick and simple pet script where it should follow you. All works fine at the start (the pet appears next to u) but when you move the pet does not follow. I am not sure why though.
local pet = script.Parent
function givePet (player)
if player then
local character = player.Character
if character then
local humRootPart = character.HumanoidRootPart
local newPet = pet:Clone ()
newPet.Parent = character
local bodyPos = Instance.new("BodyPosition", newPet)
bodyPos.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
local bodyGyro = Instance.new("BodyGyro", newPet)
bodyGyro.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
while wait() do
bodyPos.Position = humRootPart.Position + Vector3.new(2, 2, -1)
bodyGyro.CFrame = humRootPart.CFrame
end
end
end
end
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
givePet(player)
end)
end)
I don’t see anything wrong with the script so my guess is it could be one of the settings on the object but not sure what would be stopping this (anchored is off).
Have you made sure your pet has a correct rig? Show me how it looks like in the explorer tab
Also, your script makes it so that when it clones a pet, that script also gets cloned as well. So you should delete that cloned script in the cloned pet model.
Also in regards to the cloning thing I know its just for now for testing. I will change it later on but I don’t think it should cause an issue like this.
Came up with an idea:
Constantly check for the player’s position, and update the pet’s position relative to that position
Example
--this would be a script within the pet
while true do
wait(0.01)
local OriginPointX = character.RightLeg.Position.X
local OriginPointY = character.RightLeg.Position.Y
local OriginPointZ = character.RightLeg.Position.Z
local PetPositionX = OriginPointX - 0.6
local PetPositionY = OriginPointY - 0.15
local PetPositionZ = OriginPointZ + 0.1
script.Parent.Position = (PetPositionX, PetPositionY, PetPositionZ)
end
You’re gonna want to use AlignPosition and AlignOrientation objects for this, specifically on TwoAttachment mode. The way these work is they attempt to match the position/rotation of attachments, which would cut down on the performance impact since it’s physics based.
I’d imagine you would add an attachment in the character that is off to the side of the player, then create one at the center of the pet, like so:
yea but also I want to make it so the pet will hover up and down a little when they are still which if I am correct should not be possible via the way ur saying??
You could use TweenService to move the attachment up and down forever (by setting the repeat count of a TweenInfo to -1), which would probably be what you’re looking for.
My bad, didn’t notice that. I don’t see the point of having the bodyGyo.CFrame = humRootPart.CFrame
Also, try to use less variables. Sometimes, if you use too many variables, you can accidentally change something that is a value and not the actual thing you want. I don’t know if you understand what I mean, but I hope you do. Try replacing all instances of humRootPart.CFrame with character.HumanoidRootPart