You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve?
I am trying to accomplish my goal for my BotService Module. Making bots being able to swim like players. -
What is the issue?
I managed to show what I almost accomplished.
seems pretty normal but…
they just look like this (close up view)
this also happened when touching a part while swimming -
What solutions have you tried so far?
I tried asking ChatGPT (don’t make fun of me) but the result was good but wasn’t fixing this.
Did I search on the devform?
Yes, but also that didn’t work.
Is there anyway to help out? because My BotService was supposed to represent NPC Players/Fake Players w/ params.
function MoveUntilFinished(Humanoid: Humanoid, TargetPosition: Vector3, Timeout: number?, OnComplete: () -> ())
if not Humanoid.Parent then
return
end
local Done = Instance.new("BindableEvent")
Done.Event:Connect(function()
Humanoid:Move(Vector3.new(0, 0, 0))
-- Call the OnComplete callback if provided
if OnComplete then
OnComplete()
end
end)
local SteppedConnection = nil
local DebugPart = nil
if debugLocation then
local Torso = Humanoid.Parent:FindFirstChild("Torso")
if Torso then end
DebugPart = Instance.new("Part")
DebugPart.Position = TargetPosition
DebugPart.Size = Vector3.new(0.25, 0.25, 0.25)
DebugPart.Material = Enum.Material.Neon
DebugPart.BrickColor = BrickColor.new("Lime green")
DebugPart.CanCollide = false
DebugPart.CanQuery = false
DebugPart.CanTouch = false
DebugPart.Anchored = true
DebugPart.Parent = game.Workspace
end
local HRP = Humanoid.RootPart; HRP:SetNetworkOwner(nil)
local MoveToYAdjusted = (HRP ~= nil) and Vector3.new(TargetPosition.X, HRP.Position.Y, TargetPosition.Z) or Vector3.new(0, 0, 0)
Humanoid:Move(MoveToYAdjusted)
local lastYPosition = nil
local stuckYTime = 0
local stuckYThreshold = 1.5 -- Seconds before considering it stuck bobbing
local yOscillationThreshold = 0.2 -- How much Y position must change to count as bobbing
SteppedConnection = RunService.Stepped:Connect(function(_, deltaTime)
if HRP then
MoveToYAdjusted = Vector3.new(TargetPosition.X, HRP.Position.Y, TargetPosition.Z)
if Humanoid:GetState() == Enum.HumanoidStateType.Swimming then
MoveToYAdjusted = TargetPosition
end
local Distance = (HRP.Position - MoveToYAdjusted).Magnitude
-- Normal movement
if Distance <= 1.33 then
Done:Fire()
else
Humanoid:Move((MoveToYAdjusted - HRP.Position).Unit)
end
else
Done:Fire()
end
end)
-- Timeout logic
task.delay(Timeout, function()
Done:Fire()
end)
Done.Event:Wait()
if SteppedConnection ~= nil then
SteppedConnection:Disconnect()
end
if DebugPart then
DebugPart:Destroy()
end
end