Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why does this simple pet script keep bugging out so much?

Asked by 5 years ago

I have a script for one of my games which is inside of a part. This script is meant to make the part float, the part is located inside of the HumanoidRootPart. For some reason if you have multiple pets equipped or if someone walks into one of your pets, they fly to the middle of the map and stay there until you touch them again. I have no idea why this is happening. CanCollide is off and they are UnAnchored.

Here is the code:
local head = script.Parent.Parent.Parent:FindFirstChild(“Head”)

local pet = script.Parent

while true do

wait()

local p = head.CFrame * Vector3.new(2,1,2.2)

pet.BodyGyro.CFrame = head.CFrame

pet.BodyPosition.Position = Vector3.new(p.x,p.y,p.z)

end

Answer this question