#"Delay problem"

1 messages · Page 1 of 1 (latest)

surreal totem
#

So the thing is, I am making a simple dash in each side, and it works, but the delay is a big problem:
If the LinearVelocity will be created in server script, the client that performed a dash and other people will see the delay between input and animation start (which is on local script) and the server script code start (The example on video is showcase what client see if LV was created on server)
If LV will be created on client, the client will not have a delay, but other clients and server will see it with a same delay between animation start and the player started moving, and + the client will have full access to LV, which is not really safe.

I'm new to code and don't know much, and I spent 2 days trying to figuring it out, but nothing. Other games with similar dashes don't have this problem, and I don't even know what to type on google to find the solution. Please help

(Also, on video I have an average ping of 80ms)

surreal totem
midnight plume
#

animate on the client

#

do both on the client

midnight plume
surreal totem
midnight plume
#

do both on the client

#

there will be no visible delay

#

between the velocity and the animation that is

#

for all other clients

#

do i really need to qualify everything? i think i'm just saying stuff for the sake of saying stuff again, i do that sometimes mah bad

surreal totem
#

ill do that now, if you want you can join the game in a minute to see

midnight plume
#

i dont need to i already know what this problem is and how to deal with it ;o

#

animations and physics made to a player's local character are sent to server then gets replicated to everyone, so you can safely do everything on the localplayer character without problem. you're still contending with roblox's chosen method of dealing with the problem, that is, not at all that's why exploiters can fly in the first place, but hey if you don't know this problem like i do i can assure you, just do it all on the client and you'll be fine, no worse off than any other game that does this which is most of them.

#

or you can simply do it all on the server and thus only the localplayer has input delay, which is how tsb does it.

#

yeah it has input delay coz its all server and none yall notice coz your ping always 50ms on nearby servers.

surreal totem
north spruce
#

that has any sort of keyboard mechanics or sum

#

😭

midnight plume
#

literally every multiplayer game, yes.

#

any online component subject to latency

#

plus roblox has deliberate physics delay so there's that too

surreal totem
#

the client that dashes has no delay, but the client-spectator has a delay between the animation and the dash movement

midnight plume
#

animate on the client

#

that is only the client doing the dash

surreal totem
opaque turtleBOT
#

studio** You are now Level 2! **studio

surreal totem
#

everything is on the client

#

except the trail but there is no problem with trail effect

midnight plume
#

probably still have leftover code

surreal totem
coarse hearth
#

I agree with @midnight plume that you should handle the movement client sided. Just add an anticheat and a bypass for the lv in the future.

surreal totem
#

its not about the animation, the animation runs on time

surreal totem
#

there is also a visual bug: You can move players, but only the client that dashes can see that he is moving someone. Not critical but annoying

#

if someone want to help me, here is the local script:

local UIS = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")
local RunService = game:GetService("RunService")

local Animations = require(game.ReplicatedStorage.AnimationsModule)
local Camera = workspace.CurrentCamera
local RE = game.ReplicatedStorage.RemoteEvents.Player.Dash

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local HRP = Character:WaitForChild("HumanoidRootPart")

while not Player:GetAttribute("GameCharacter") and not Player.Character do
    task.wait()
end

Animations:LoadAnimations(Player.Character)

Animations:GetAnimation("Player", "Dash_W").Priority = Enum.AnimationPriority.Action2
Animations:GetAnimation("Player", "Dash_A").Priority = Enum.AnimationPriority.Action2
Animations:GetAnimation("Player", "Dash_S").Priority = Enum.AnimationPriority.Action2
Animations:GetAnimation("Player", "Dash_D").Priority = Enum.AnimationPriority.Action2
#
local DashStrength = 90
local Duration = 0.12
local CooldownTime = 0.2
local MinStrength = DashStrength * 0.15
local StrengthRemoval = DashStrength / (Duration / 0.01)

local function Dash(Direction)
    local Strength = DashStrength
    local StartTick = tick()
    
    local Att = HRP:FindFirstChild("DashAttachment") or Instance.new("Attachment", HRP)
    local LV = Instance.new("LinearVelocity")
    LV.Attachment0 = Att
    LV.MaxForce = 1e5
    LV.RelativeTo = Enum.ActuatorRelativeTo.World
    LV.Parent = HRP

    RE:FireServer()

    local Connection
    Connection = RunService.Heartbeat:Connect(function(DT)
        local Elapsed = tick() - StartTick

        local CamLook = Camera.CFrame.LookVector
        local Yaw = math.atan2(CamLook.X, CamLook.Z) + math.pi
        HRP.CFrame = CFrame.new(HRP.Position) * CFrame.Angles(0, Yaw, 0)

        if Direction == "Forward" then
            LV.VectorVelocity  = HRP.CFrame.LookVector * (DashStrength - StrengthRemoval)
        elseif Direction == "Back" then
            LV.VectorVelocity  = -HRP.CFrame.LookVector * (DashStrength - StrengthRemoval)
        elseif Direction == "Right" then
            LV.VectorVelocity  = HRP.CFrame.RightVector * (DashStrength - StrengthRemoval)
        elseif Direction == "Left" then
            LV.VectorVelocity  = -HRP.CFrame.RightVector * (DashStrength - StrengthRemoval)
        end    
        
        local D = StrengthRemoval * (DT / 0.01)
        Strength = Strength - D
        if Strength < MinStrength then
            Strength = MinStrength
        end

        if Elapsed >= Duration then
            Connection:Disconnect()
            LV:Destroy()
            Att:Destroy()
        end
    end)
end
#

UIS.InputBegan:Connect(function(Input, GPE)
    if GPE then return end

    if Input.KeyCode == Enum.KeyCode.Q then

        if UIS:IsKeyDown(Enum.KeyCode.W) then
            Dash("Forward")
            Animations:GetAnimation("Player", "Dash_W"):Play()
        elseif UIS:IsKeyDown(Enum.KeyCode.S) then
            Dash("Back")
            Animations:GetAnimation("Player", "Dash_S"):Play()
        elseif UIS:IsKeyDown(Enum.KeyCode.A) then
            Dash("Left")
            Animations:GetAnimation("Player", "Dash_A"):Play()
        elseif UIS:IsKeyDown(Enum.KeyCode.D) then
            Dash("Right")
            Animations:GetAnimation("Player", "Dash_D"):Play()
        else
            Dash("Forward")
            Animations:GetAnimation("Player", "Dash_W"):Play()
        end
    end
end)
#

(its all 1 script)

midnight plume
#

why do you need this if it is all clientside RE:FireServer()

azure cliff
# surreal totem but other people will see the delay

Had this too just create the linear velocity if it doesn’t exist yet only on one client ska the player that activated it and just set maxforce to 0 when disabling it, don’t destroy it if you keep removingn and adding it it will cause the said delay

coarse hearth
#

That'll cause input delay for the client but everyone will see the same thing.

surreal totem
#

Okay, thank you so much vvv and adsfasdf

surreal totem
#

still thanks

azure cliff
#

It looks unnatural

surreal totem
opaque turtleBOT
#

studio** You are now Level 3! **studio

coarse hearth
surreal totem
surreal totem
#

on a video its fast

#

bruh

#

but there is a delay

surreal totem
opaque turtleBOT
#

studio** You are now Level 4! **studio

coarse hearth
surreal totem
#

its like 30 ping I have

coarse hearth
surreal totem
#

I'm not that fluent in english and have problems with explaining things

coarse hearth
#

I cant right now

surreal totem
#

yeah

coarse hearth
#

If that's the issue then that is completely normal

#

Since u handle things on the client, it will always see things first

surreal totem
#

yeah, I understand

#

but I never saw this issue in other games

coarse hearth
surreal totem
#

No, I think you didnt understand

#

the issue is that when the animation starts, the BV should start as well

#

at the same time

#

but other client see the performer running animation, and only after some period of time, he moves

surreal totem
surreal totem
#

and only after some time, the LV

surreal totem
# surreal totem same for knockback

I added a white highlight, and the highlight LV runs earlier in the code, but you see highlight first, and only then you see player moving

coarse hearth
#

Are you still creating and destroying the velocity attachment?

coarse hearth
# surreal totem no

I don't think this would solve it did you play the animation before or after the lv?

surreal totem
#

animation is at the end of the code

#

the LV is the first thing

coarse hearth
coarse hearth
#

Yeah so it seems that you create one for the first knockback

#

What you can try to do is create it when the player first joins

coarse hearth
#

If it's a client script then I have a few concerns

surreal totem
#

in SSS

coarse hearth
#

Alright

#

You play the animation on the server?

surreal totem
#

the damaged animation yeah

coarse hearth
#

What about the attack animation?

surreal totem
#

its local, but the M1 logic is on server

coarse hearth
surreal totem
#

what do you mean

coarse hearth
#

Ok only do this if my first solution doesn't work, but do a fireall to clients to apply the knockback to your character

#

When the server does physics, there's a noticeable delay for the client

#

Also since the attack animation is on the client, you need to expect some delay between the server and the attack, but I'm sure you know that.

surreal totem
coarse hearth
surreal totem
coarse hearth
#

Let me know if the solution works

surreal totem
opaque turtleBOT
#

studio** You are now Level 5! **studio

surreal totem
#

thanks

surreal totem
#

and here is local script

coarse hearth
surreal totem
#

used print to check if its not nil or something else, its working

#

I asked AI and it doesn't know as well...

coarse hearth
surreal totem
azure cliff
#

Only the player ur applying the knockback on

surreal totem
#

@coarse hearth