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

Pets keep flying to middle of map for no reason?

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

0
I found this problem out too when I was using this same script I think its because it glitchs with other things (like other players) and cant to fix its problem the pet flies to the middle of the map I havent found a answer yet but I think it something to do with "local head = script.Parent.Parent.Parent:FindFirstChild(“Head”)" I hope someone soon with find out how to fix the problem Good Luck! DevvUnknown 3 — 5y
0
bumping because i still need help :( mrorangethegamer 81 — 5y

1 answer

Log in to vote
0
Answered by
b3wz 34
5 years ago

this should work, although havent completely tested, but should give you an idea.

local pet = script.Parent
local head = script.Parent.Parent.Parent:FindFirstChiild("Head")
local offset = CFrame.new(2,1,2.2)
while pet and head do
    pet.BodyGyro.CFrame = head.CFrame
    pet.BodyPosition.Position = CFrame.new(head.CFrame * offset).p
    wait()
end
0
it says p is not a valid member of vector3 on line 6 (i had to change cframe to vector3) mrorangethegamer 81 — 5y
0
where it says local offset = cframe.new change cframe to vector3 and then keep the rest b3wz 34 — 5y
0
it does work now but it is the exact same as before, it keeps getting stuck in the middle. mrorangethegamer 81 — 5y
Ad

Answer this question