I have Disco?, OiiTaru#1402
If that’s any good?
I have Disco?, OiiTaru#1402
If that’s any good?
Here is a file place with a pet that follows. Maybe this can help you.
All the code is inside the Pet Model under workspace.
Made some more steps in whichever direction.
However, as you can see from the video below:
The Pet follows the Player when they’re at the edge of the cylinder;
However, due to stopping when in the cylinder, it causes the jitteryness shown below.
local v3 = Vector3.new(1, 0, 1)
local CanFollow = false
while true do wait()
local Pos1 = Walker["Torso"].Position
local Pos2 = HumanoidRootPart.Position
local Dist = (Pos1 - Pos2) * v3
local Magnitude = Dist.Magnitude
local NewSpeed = (Humanoid.WalkSpeed or 16) * math.clamp(1 + 0.07 * (Magnitude - 3.5 - 3), 0.4, 5)
Walker["Humanoid"].WalkSpeed = NewSpeed
if not CanFollow then
Walker["Humanoid"]:MoveTo(Pos1)
else
Walker["Humanoid"]:MoveTo(Pos2)
end
if (Pos1 - Pos2).Magnitude > 5 then
CanFollow = true
elseif (Pos1 - Pos2).Magnitude < 5 then
CanFollow = false
end
end
I believed I have reply to you before somewhen before, but anyways, I did some testing in loomian legacy, where I tried to get my loomians stuck… Actually, they path find towards you instead of using move to, so
player move out of distance (the magnitude of the difference between the two)
repeat
pathfind + moveTo
until length < desired distance
also, use collision group either for the pet or the player, I believe that take some lag off as well
for the moveTo time out or path finding time out (they are really both moveTo, except pathfinding creates a path with way points for it to move to)
–refers back to api reference for the timeout
https://developer.roblox.com/en-us/api-reference/function/Humanoid/MoveTo
local function moveTo(humanoid, targetPoint, andThen)
local targetReached = false
-- listen for the humanoid reaching its target
local connection
connection = humanoid.MoveToFinished:Connect(function(reached)
targetReached = true
connection:Disconnect()
connection = nil
if andThen then
andThen()
end
end)
-- start walking
humanoid:MoveTo(targetPoint)
-- execute on a new thread so as to not yield function
spawn(function()
while not targetReached do
-- does the humanoid still exist?
if not (humanoid and humanoid.Parent) then
break
end
-- has the target changed?
if humanoid.WalkToPoint ~= targetPoint then
break
end
-- refresh the timeout
humanoid:MoveTo(targetPoint)
wait(6)
end
-- disconnect the connection if it is still connected
if connection then
connection:Disconnect()
connection = nil
end
end)
end
A YouTuber called HowToRoblox Has a Pet System Tutorial