I’ve been loading and playing animations on the server.
Player presses a button > Fires to server > Plays a punch animation and damages etc.
But I’m wondering if I should do a OnClientEvent to play the animations or maybe preload the animations?
I was just going to load and play animations on the client based on the combo the player is on but I need it to align with the hitbox. Like if I use GetMarkerReachedSignal I need that on the server to spawn the hitbox and damage along with other stuff. So that’s going to be my last option.
Example Client Script
local Player = game:GetService("Players").LocalPlayer
local Char = Player.Character or Player.CharacterAdded
local Humanoid = Char.Humanoid
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UserInputService = game:GetService("UserInputService")
local TriggerAnim = ReplicatedStorage.TriggerAnim
UserInputService.InputBegan:Connect(function(input, gpe)
if gpe then return end
if input.KeyCode == Enum.KeyCode.E then
TriggerAnim:FireServer()
end
end)
TriggerAnim.OnClientEvent:Connect(function(AnimationToPlay)
local Track = Humanoid.Animator:LoadAnimation(AnimationToPlay)
Track:Play()
end)
Example Server Script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TriggerAnim = ReplicatedStorage.TriggerAnim
TriggerAnim.OnServerEvent:Connect(function(player)
TriggerAnim:FireClient(player, ReplicatedStorage:WaitForChild("LightAttack1"))
end)