while wait(1) do
local player = script.Parent.Owner.Value
if workspace[player] then
local character = workspace[player]
if(script.Parent.PetMain.Position - character.HumanoidRootPart.Position).Magnitude > 25 then
script.Parent.PetMain.CFrame = -- How will I get my back CFrame to rotate it to there?
end
end
end)
local pet -- pet mesh / part
local character -- character model
function attach(character, pet)
local root = character:WaitForChild("HumanoidRootPart")
local position = root.CFrame
pet.CFrame = position
pet.Anchored = true
local weld = Instance.new('WeldConstraint', pet)
weld.Name = 'pet weld'
weld.Part0 = pet
weld.Part1 = root
pet.Anchored = false
return weld
end
attach(character, pet)
You should CFrame the pet on the client. I am assuming you’re doing it on the server as you aren’t defining player as Players.LocalPlayer. It’s unnecessary doing it on the server.