EDIT: I made the map semi-transparent so i can see the pet, it just falls forever
I'm trying to understand how pets work in the game, so I've done a bit of experimenting, and this is what I have:
local newPet = script.Parent newPet.CanCollide = false newPet.Anchored = false local petPos = Instance.new("BodyPosition", newPet) local petGyro = Instance.new("BodyGyro", newPet) petGyro.MaxTorque = Vector3.new(900000,900000,900000) local owner = newPet.ID.Value local followPosition = Vector3.new(2,2,0) while wait(1) do local ownerObj = workspace:WaitForChild(owner) local player = game.Players:FindFirstChild(ownerObj.Name) local ownerPos = ownerObj.HumanoidRootPart.Position local stopAt = ((ownerPos - newPet.Position).magnitude - 1) * 1000 petPos.P = stopAt petPos.Position = ownerPos + followPosition petGyro.CFrame = ownerObj.HumanoidRootPart.CFrame end
the pet is for just me, and i have a string value of my username in the pet, when I join the pet just disappears. I've changed the pet, and it still disappears, no error messages. Please help me, I'm brand new to coding.
I think i found the problem, on line 08 the BodyGyro MaxTorque are tho high, so its will result an fling problem or on the line 10, can you tell where the pet goes?
wait put a script on the pet, and after that, please tell me what the output says
local pet = script.Parent pet.Changed:Connect(function() print('Location: '..pet.Position) end)