#what could possibly make my units movement laggy sometimes, i use LinearVelocity and BodyGyro and i

1 messages · Page 1 of 1 (latest)

fallen idol
#
    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 
burnt pagoda
#

lemme take a look

fallen idol
#

k

burnt pagoda
#

I dont see frame drop what are you talking about?

fallen idol
#

ik

#

i was talking about the little units lagging

#

you see they stop for 1 second then move again

burnt pagoda
#

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

fallen idol
#

it's not client sided

#

it's server sided

burnt pagoda
#

yeah I know that

fallen idol
#

oh ok

burnt pagoda
#

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

fallen idol
burnt pagoda
#

if the soldiers move smoothly its a replication issue

fallen idol
#

i was thinking it might be smth from the linearvelocity

burnt pagoda
fallen idol
#

no

#

same thing