if #validUnits == 0 then return end
local totalUnits = #validUnits
if totalUnits == 1 then
local unit = validUnits[1]
local unitPosition = position
gridPositions[1] = unitPosition
positions[unit] = unitPosition
local loop = true
rp.Remotes.MakeBeam:FireClient(plr, unit, unitPosition, false)
coroutine.wrap(function()
if unit.Hitbox then
unit.Hitbox.BodyGyro.D = 150
while loop and unit and unit.Parent and positions[unit] == unitPosition do
unit.Hitbox.LinearVelocity.PlaneVelocity = V2(
unitPosition.X - unit.Hitbox.Position.X,
unitPosition.Z - unit.Hitbox.Position.Z
).Unit * unit:GetAttribute("Speed")
unit.Hitbox.BodyGyro.CFrame = CFrame.lookAt(
unit.Hitbox.Position,
V3(unitPosition.X, unit.Hitbox.Position.Y, unitPosition.Z)
)
local posDelta = unit.Hitbox.Position - positions[unit]
local xzDistance = math.sqrt(posDelta.X * posDelta.X + posDelta.Z * posDelta.Z)
if xzDistance <= 1 then
loop = false
break
end
task.wait(0.05)
end
if unit and unit.Parent then
if positions[unit] ~= unitPosition then
rp.Remotes.MakeBeam:FireClient(plr, unit, unitPosition, true)
end
if not loop then
unit.Hitbox.LinearVelocity.PlaneVelocity = V2(0, 0)
rp.Remotes.MakeBeam:FireClient(plr, unit, unitPosition, true)
end
end
end
end)()
return
end
#what could possibly make my units movement laggy sometimes, i use LinearVelocity and BodyGyro and i
1 messages · Page 1 of 1 (latest)
lemme take a look
k
I dont see frame drop what are you talking about?
ik
i was talking about the little units lagging
you see they stop for 1 second then move again
oh yeah thats a serverside issue
moving them on the client might be unsecure so let me edit the script for so their is no stopping or lag
yeah I know that
oh ok
I could see from the video
the issue is happening because replication
is it neccasry for you to run on server?
oh yeah it is
wait sec
yea and idk if i want to do client replication i don't think it will fix the problem
I think it will mind checking the soldiers moving in the serverside view instead?
if the soldiers move smoothly its a replication issue
i did same thing
i was thinking it might be smth from the linearvelocity
oh so where the soldiers moving smoothly?