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.