Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Pets keep flying to middle of map for no reason?

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

2 comments

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!

0

bumping because i still need help :(

1 answer

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

3 comments

0

it says p is not a valid member of vector3 on line 6 (i had to change cframe to vector3)

0

where it says local offset = cframe.new change cframe to vector3 and then keep the rest

0

it does work now but it is the exact same as before, it keeps getting stuck in the middle.

This discussion is preserved as it was. New answers, comments, and votes are closed.