I’m having an issue with my animations where it will stop on the Server, but not the Client. A script requires a module that plays the animations with functions.
Here’s an example of the Animation:
(The left side is what the Server sees, the right side is the Client.)
The left side is what’s supposed to happen across the Server AND Client, but it does not work properly on Client-side.
Here is the ServerScript requiring my Animation module (Simplified):
wait(.3)
local Character = script.Parent
local Player = game.Players:GetPlayerFromCharacter(Character)
local Conditions = Character.Conditions
local LocalConditons = Character.LocalConditions
local Bindables = Character.Bindables
local LastStun = tick()
local LastStunAnim
local function urequire(module)
assert(typeof(module) == "Instance" and module:IsA "ModuleScript", "urequire only works with module script instances")
local newModule = module:Clone()
newModule.Parent = module.Parent
module.Parent = nil
local value = require(newModule)
module.Parent = newModule.Parent
newModule:Destroy()
return value
end
local Animation = urequire(game:GetService("ReplicatedStorage").Modules.Animation2)
Animation.AnimationData.Source = game.ReplicatedStorage.StunAnimations
Animation.AnimationData.Character = Character
Animation.AnimationData.Player = Player
local Framework = urequire(game:GetService("ServerScriptService").Framework)
Framework.FrameworkData.Character = Character
Framework.FrameworkData.Player = Player
local function Reset()
Framework.SetNetwork("Return",Character)
end
local function WakeUp()
Reset()
end
HitStuns = {}
HitStuns["HighHit"] = {
["CurrentAnimation"] = Animation.LoadAnimation("HighHit");
["Action"] = function(self,Settings)
local StunTime = Settings["StunTime"]
self["CurrentAnimation"].TimePosition = 0
Animation.RunAnimation(self["CurrentAnimation"],.1,1)
Conditions.LayingDown.Value = false
local AnimationLength = self["CurrentAnimation"].Length*.99
local Modify = false
if AnimationLength / self["CurrentAnimation"].Speed > StunTime then
Modify = true
repeat
local speed = self["CurrentAnimation"].Speed + 0.01
Animation.ChangeSpeed(speed)
task.wait()
until StunTime < (AnimationLength / self["CurrentAnimation"].Speed)
end
if Modify == true then
task.delay(AnimationLength / self["CurrentAnimation"].Speed,function()
Animation.PauseAnimation()
end)
else
task.delay(AnimationLength,function()
Animation.PauseAnimation()
end)
end
task.spawn(function()
repeat task.wait()
local function DoThing()
if tick() - LastStun > StunTime then
Animation.StopAnimation(0)
WakeUp()
return true
end
end
until DoThing() == true
end)
end,
}
Bindables.Stun.Event:Connect(function(Attacker,StunSettings)
local StunType = StunSettings["StunType"]
Framework.SetNetwork("Set",Character,game:GetService("Players"):GetPlayerFromCharacter(Attacker))
LastStun = tick()
if LastStunAnim ~= nil then
LastStunAnim:Stop()
end
if HitStuns[StunType] then
HitStuns[StunType]:Action(StunSettings)
LastStunAnim = HitStuns[StunType]["CurrentAnimation"]
else
warn(StunType .. " Not Found!")
end
end)
Here is the Animation Module itself(Not whole script, snipped for relativity and simplicity purposes.):
function Module.StopAnimation(FadeOut)
local PlaceHolder = Module.AnimationData.CurrentAnim
if Module.AnimationData.CurrentAnim ~= nil then
Module.AnimationData.CurrentAnim:Stop((tonumber(FadeOut or 0.1)))
if PlaceHolder == Module.AnimationData.CurrentAnim then
Module.AnimationData.CurrentAnim = nil
end
else
warn("Function [ StopAnimation ] error occured :"..tostring(script))
end
end
function Module.LoadAnimation(Animation,CustomSource)
if typeof(Animation) == "string" then
local SourceViable
if CustomSource == nil or false then
SourceViable = false
else
print(tostring(CustomSource) .."Line 39")
print(tostring(Animation).."line 40")
if CustomSource:FindFirstChild(tostring(Animation),true) == nil then
warn("Animation ["..tostring(Animation).."] not found within ["..tostring(CustomSource).."] :"..tostring(script))
elseif CustomSource:FindFirstChild(tostring(Animation),true) ~= nil then
print("source viable is true")
SourceViable = true
end
end
if SourceViable == true then
return Module.AnimationData.Character.Humanoid.Animator:LoadAnimation(CustomSource:FindFirstChild(tostring(Animation),true))
elseif SourceViable == false then
return Module.AnimationData.Character.Humanoid.Animator:LoadAnimation(Module.AnimationData.Source:FindFirstChild(tostring(Animation),true))
else
warn("ViableSource undefined :"..tostring(script))
end
print(tostring(SourceViable).."line54")
elseif typeof(Animation) == "Instance" then
if Animation then
return Module.AnimationData.Character.Humanoid.Animator:LoadAnimation(Animation)
else
warn("Animation undefined ["..tostring(Animation).."] :"..tostring(script))
end
end
end
function Module:RunAnimation(FadeIn, Speed,FadeOut)
local Animation = self
if Module.AnimationData.CurrentAnim ~= nil and not (Module.AnimationData.CurrentAnim == self and self.Looped == true) then
Module.StopAnimation(FadeOut or 0.1)
end
Module.AnimationData.CurrentAnim = Animation
if Module.AnimationData.CurrentAnim == self and self.Looped == true then
print("Repeating Animation Constant")
end
if Module.AnimationData.CurrentAnim == nil then
warn("NIL VARIABLE")
end
Animation:Play(FadeIn or .2, 1, Speed or 1)
end
Has anyone encountered this issue and fixed it or debugged it? I can’t figure this out.