Help with Input/Move system

I want to make a power system, where depending on what key you press it does a certain move based on the current power of the player. However, I also want those powers to have smooth VFX, meaning the VFX has to be played on the client. My goal is to create a system where I can easily add more powers.

Here is what I currently have:
The powers and the moves are going to be module script, here is a rough example of one

local human = {}
human.__index = human

function human.new(player)
	local self = setmetatable({}, human)
	
	self.player = player
	self.name = "Human"
	self.animTracks = {}
	
	return self
end

function human:E() --no sanity checks yet
	local hum = self.player.Character:FindFirstChild("Humanoid")
	self.animTracks.punch = hum:LoadAnimation(script.Animations.Punch)
	self.animTracks.punch:Play()
end

return human

The moves are then called from a server script whenever a user presses a button, based on the users power:

game:GetService("Players").PlayerAdded:Connect(function(player)
	local stat = game:GetService("ServerStorage"):WaitForChild("Stats"):Clone()
	stat.Parent = player
	stat.Power.Value = "Human"
	
	player.CharacterAdded:Connect(function(char)
		local power = require(game.ServerScriptService.Powers[player:FindFirstChild("Stats").Power.Value]).new(player)
		game.ReplicatedStorage.InputEvents.EDown.OnServerEvent:Connect(function(p)
			if p ~= player then return end
			power:E()
		end)
	end)
	
end)

The issues I’m having is that with this system, I can’t play animations on the client, and I would have to do all the VFX on the server, which would cause a lot of lag. What can I do to improve this system? Or what can I change to make the animations and VFX play locally.

Here is an example of what I’m looking to do:

If you stumbled upon a similar topic please let me know because I have not found any information on this whatsoever.

1 Like

Never really made a system like this before but if I were to make one here’s how I would do it:

When the user presses a button, play the animation on their client (which replicates to all clients).

For the VFX, send a remote event to all clients with the appropriate information to render the VFX.

2 Likes

So should I make 2 module scripts? One for the client and one for the server, and they will communicate when the same move happens?

1 Like

You should make a local script to detect all inputs for the moves and load the animations.

After doing simple sanity checks and cooldowns, it will play the animation client side (which will automatically replicate to all other clients).

The local script will then send a RemoteEvent to the server which will do the bigger sanity checks, send a RemoteEvent to all clients giving information about VFX, and determine all the important things that need to happen.

1 Like

Thanks for your reply. This does make sense and I tried it out but how would I check what power the user has? I don’t understand how I would call the move based on the power that the player has, since every power will have unique moves.

1 Like

Question 1: Does the player have certain moves bound to certain keys?

Question 2: Can the player use only one power at a time?

If the player has binded moves, you can just send a RemoteEvent when they use the keybind of that move.

If they can only use one power at a time then you can send a RemoteEvent when they choose their power to the server, telling it what powere they have chosen.