--pet script
local pet = script.Parent
function equipPet(plr)
if plr then
local char = plr.Character
if char then
local humrtpt = char.HumanoidRootPart
local clone = pet:Clone()
clone.Parent = char
local petpos = Instance.new("BodyPosition", clone)
petpos.MaxForce:FuzzyEq(Vector3.new(math.huge, math.huge, math.huge))
local petgyr = Instance.new("BodyGyro", clone)
petgyr.MaxTorque:FuzzyEq(Vector3.new(math.huge, math.huge, math.huge))
while wait() do
petpos.Position = humrtpt.Position + Vector3.new(3,2,3)
petgyr.CFrame = humrtpt.CFrame
end
end
end
end
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
equipPet(plr)
pet.WeldConstraint.Part1 = char:FindFirstChild("HumanoidRootPart")
end)
end)
please elaborate more, errors? put print statements all over to see where it is stopping. What is the logical error and be descriptive.
Maybe the Pet is falling to the void?
no there are no errors. I can check where it stops with prints.
no its just not moving when I turn cancollide to false. I only see the part.
“Not working”? Does that mean not equipping, not moving, not being welded to the player?
Please let us know what you want to happen and what is happening so we know what to look for.
Also you are using a BodyPosition to maintain the position of the pet relative to the player, but when you equip it you weld it to the HumanoidRootPart (but you don’t specify Part0?).
Seems like doing the same thing twice to attach the pet to the player.
I want the pet to fly after the player. it works but when I turn on cancollide it doesn’t move anymore. I’m trying to solve it but I don’t find any errors.
I’ve already tried copying every line but it doesn’t stop anywhere.
I welded part1 to the humanoidrootpart and part0 to the pet
Is the player able to move?
Try going into the Player Pet in the Workspace, not the one in the Player folder while testing to see if it’s welded and where it’s connected. Check with “Show Welds” and “Draw on Top” in the Model tab at the top of your Studio screen. The green line that indicates the weld should show up if it’s active.
Why are you putting forces in it to offset it when you equip the pet and then Welding the Pet to the Player after the function has run?
There are also other items under CanCollide like CanTouch or CanQuery. They shouldn’t affect your situation, but maybe try playing with those options.
I did but when I switch cancollide to false the pet doesn’t move anymore… when I try the other options nothing happens to the pet except what that option is for. Very strange but I don’t know what to do about it.
it worked anyway, by switching cancollide from the clone to false and not from the original pet. I don’t understand why it didn’t just work with the original pet but I solved the problem.
thanks for your help everyone and good job