Why do my pets go away when I touch them

Hello, I’m working on a game with pets and for some reason the pets disappear when you touch it. image

Script

local char = script.Parent.Parent
local pet = script.Parent
local hum = char:WaitForChild(“Humanoid”)
local torso = char:WaitForChild(“UpperTorso”)

local maxFloat = 1
local floatInc = 0.025
local sw = false
local fl = 0

while true do
wait()
if not sw then
fl = fl + floatInc
if fl >= maxFloat then
sw = true
end
else
fl = fl - floatInc
if fl <=-maxFloat then
sw = false
end
end
if pet ~= nil and hum ~= nil and torso ~= nil then
if hum.Health >= 0 then
local cf = torso.CFrame * CFrame.new(3,2+fl,3)
pet:WaitForChild(“BodyPosition”).Position = Vector3.new(cf.x,cf.y,cf.z)
pet:WaitForChild(“BodyGyro”).CFrame = torso.CFrame * CFrame.new(3,0,-3)
else
break
end
end
end

1 Like

i recommend removing “break” and make sure the pet is only a part and has no other scripts that can cause this

1 Like

Also the pet has 3 parts. 2 parts and 1 decal. 1 part that’s inside the forcefeild object doesn’t seem to come along with the pet.

you dont need a forcefield unless your trying to seperate the pets from each other,if yes you use studGap

1 Like

You can use studGap to put a gap between each pet if that is what your looking for also

1 Like

No about the forcefeild I meant the material.

1 Like

The small cube inside

you dont need anything in pets but BodyGyro BodyPosition and BodyForce or nah if im mistakening

1 Like

Ok thanks for the help. I will tell my scripter to try this and if it works I will mark you as solution.

1 Like

Also i think u would be better off makign the force field the pet and just adding the pet inside then,if not then thee pet wills have weird positions

Weld it. The welding article is on https://developer.roblox.com/ , in case you don’t know – I know you probably do, but just to provide it. :smile:

Yeah but the point is having the the part inside of it.