i’ve tried doing the other stuff people did in other topics, but they didn’t work for me
i’ve done my own thing and it works, but it’s choppy and the part looks like its “teleporting” at very high speeds.
local function getNearestPlayer()
local nearestPlayer = nil
local nearestDistance = math.huge
for _, player in pairs(players:GetPlayers()) do
if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
local playerPos = player.Character.HumanoidRootPart.Position
local ballPos = Orb.primarypart.Position
local distance = (playerPos - ballPos).Magnitude
if distance < nearestDistance then
nearestPlayer = player
nearestDistance = distance
end
end
end
return nearestPlayer
end
local function track()
createForce()
Event = game:GetService("RunService").Heartbeat:Connect(function()
if chasePlayerPause then
coroutine.yield()
else
local nearestPlayer = getNearestPlayer()
if nearestPlayer then
Orb.primarypart.CFrame = CFrame.lookAt(Orb.primarypart.Position, Vector3.new(nearestPlayer.Character.PrimaryPart.Position.X, Orb.primarypart.Position.Y, nearestPlayer.Character.PrimaryPart.Position.Z))
force.Force = Orb.primarypart.CFrame.LookVector * 200000
end
end
end)
end
how would i make the movement smoother without sacrificing ping due to the amount of signals being sent?
200,000 force. what is the mass of the orb? even if it is mass 1000, it will travel at 200 studs/sec which is REALLY fast. so nothing can save it from looking like teleport. Are you sure it is the speed you want?
yeah, it’s welded to a bunch of parts which makes its mass skyrocket so i really have to crank up the force
it’s not as fast as it seems, and its in an enclosed area
if you want the exact mass, it’s 36426.42578125
also because it will run every Heartbeat, you can return if chasePlayerPause
Event = game:GetService("RunService").Heartbeat:Connect(function()
if chasePlayerPause then return end
local nearestPlayer = getNearestPlayer()
if not nearestPlayer then return end
Orb.primarypart.CFrame = CFrame.lookAt(Orb.primarypart.Position, Vector3.new(nearestPlayer.Character.PrimaryPart.Position.X, Orb.primarypart.Position.Y, nearestPlayer.Character.PrimaryPart.Position.Z))
force.Force = Orb.primarypart.CFrame.LookVector * 200000
end)
You can make a script that will just set the CFrame of the part to the CFrame of whatever you want it to follow, but use lerp. This will make it smoother
Here is an example.
while true do
workspace.Part.CFrame = workspace.Part.CFrame:Lerp(script.Parent.HumanoidRootPart.CFrame, 0.025) -- The 0.025 is how fast the object will move to my player. The lower it is, the slower it takes, the higher it is, the faster it takes.
task.wait()
end