Your error is that BodyGyro doesn’t have a member MaxForce, rather MaxTorque.
Replace bg.MaxForce with bg.MaxTorque.
Also, please don’t use the deprecated BodyGyro and BodyPosition and use their replacements AlignOrientation and AlignPosition. Your tutorial is outdated!
If you have questions about AlignOrientation and AlignPosition, dont hesitate to reply.
first of all, instead of sharing screenshots you can use the Preformatted text or
code block
using one backtick, for preformatted text or three backticks for
a code block
you can also just press the button that looks like this: </>
this helps us…
Now, regarding the pet, use humanoids;
don’t use forces or whatever.
here is a script using a humanoid and pathfindingservice, to find the path to the player, it doesn’t cover cases where the path gets blocked but yeah.
local Humanoid = --your humanoid here, you only need this for your npc to be alive, but
--you don't need it in your script
local root = --your model's root part here.
local ps = game:GetService("PathfindingService")
local path = ps:CreatePath()--empty path
path:ComputeAsync(root.Position, --add the player's pos here..;)
for _, waypoint in ipairs(path:GetWaypoints()) do
if waypoint.Action == Enum.PathWaypointAction.Jump then
humanoid.Jump = true--make the humanoid jump
end
humanoid:MoveTo(waypoint.Position) --force the npc to move to the waypoint's position
end
this is a simple example and will obviously only run once and also, fail if the path is not found.
but this is just to tell you why not to use forces, and use npcs and humanoids, because roblox provides lots of support for them, for following etc.
thank you for all this, the code runs without giving any errors, but it still doesn’t work. Do you suggest i find a different script or i try to make this one work?
I don’t think forces are the way to go, as @scavengingbot mentioned. You should look into roblox’s pathfinding service instead. I do think the fix to your current code, however, is setting bg.MaxTorque to just math.huge instead of a Vector3, and bp.MaxForce to math.huge aswell for the same reason.
you need to use tool then script it by using Equipped event
Hope this will help you
Edit: if this tutorial didnt help you try to search on browser and on youtube tutorials
thank you for this tutorial, but it isnt working perfectly. I did everything in the tutorial, but when i test it the pet seems so follow me, but doesn’t continously follow me
code:
local pet = script.Parent
function givepet(player)
if player then
local character = player.Character
if character then
local humanrootpart = character.HumanoidRootPart
local newpet = pet:Clone()
newpet.Parent = character
local bodyPos = Instance.new("BodyPosition", newpet)
bodyPos.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
local bodyGyro = Instance.new("BodyGyro", newpet)
bodyGyro.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
while wait() do
bodyPos.Position = humanrootpart.Position + Vector3.new(3,1,3)
bodyGyro.CFrame = humanrootpart.CFrame
end
end
end
end
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
givepet(player)
end)
end)