I’m making a knockback system involving dynamic knockback, where the playing is knocked back slightly left/right depending on their direction held while taking the hit.
Currently I just have a system where you have to manually change your held direction by holding the key, and then dashing in that direction while stunned. This is kind of unorthodox and not very fun/satisfying so I was wondering what else I should try.
I’ve just been using attributes for each key (WDown, SDown, etc) and then changing them with a remote event whenever the player dashes, but firing a remote event to the server every time a player changes a key would probably be super resource intensive (from what I know). I do know UserInputService:IsKeyDown(Enum.KeyCode.keyhere) exists, but I’m not sure how to implement that server-side in an If check, or how to associate it with the right player.
Just wondering what I should do with IsKeyDown or any other methods I should try
Since Roblox characters are controlled on the client, you could have the server send a remote event to the client and then have the client control the knockback effects, including whether or not the keys are held down. Since most changes applied to the character automatically replicate to the server.
Yeah true, btw are arguments passed by FireClient changable by the client? Not really important since exploiters could just fly out of combos and stuff anyways, but I imagine they are
Absolutely; the anything that makes itself onto the client is manipulable by the client. It’s their computer, their memory, their choice to process what’s being shown
Another thing about this, my system makes it so that the stun enemies take and the length of their knockback are linked (stun duration = knockback tween time) so it’s much easier to do them both in the same script.
For clarity:
Knockback.VectorVelocity = RootPart.CFrame.LookVector * KnockbackZ + RootPart.CFrame.RightVector * KnockbackX
local Goal = {VectorVelocity = Vector3.new(0,0,0)}
local KnockbackInfo = TweenInfo.new(Duration, Enum.EasingStyle.Linear, Enum.EasingDirection.In)
local KnockbackTween = TweenService:Create(Knockback, KnockbackInfo, Goal):Play()
-- The LinearVelocity is given the strenght and its tweened down to 0
-- Does this over the course of the stun duration that I give the stun module
I want the clients input but I also want to keep my stun server-side, so not really sure what to do abt it