Animation track events dont work out of studio

Basically, I am creating a dash system and it works perfectly in Roblox Studio; there are no issues with anything. However, after publishing it to my game and joining a server, the animations play but, after debugging a bit, I realized that the functions assigned to my animation events do not execute. Again, in Roblox Studio, there are no problems.

Server Script

local dashEvent = game.ReplicatedStorage:WaitForChild("DashEvent")
local enumDashDirection =require(game.ReplicatedStorage:WaitForChild("EnumDashDirection"))
local dashAnimations = {
	forward = "rbxassetid://17820636309",
	backward = "rbxassetid://17821025162"
}
local dashAnimation = Instance.new("Animation")

local function forwardDash(player)
	local linearVelocity = Instance.new("LinearVelocity")
	local attachment0 = Instance.new("Attachment")
	local humanoidRoot = player.Character:FindFirstChild("HumanoidRootPart")
	local animator = player.Character:FindFirstChild("Animator") or Instance.new("Animator")
	local hum = player.Character:WaitForChild("Humanoid")
	animator.Parent = player.Character.Humanoid
	dashAnimation.AnimationId = dashAnimations.forward
	local track = animator:LoadAnimation(dashAnimation)
	track:GetMarkerReachedSignal("DashStart"):Connect(function(paramString)
		if humanoidRoot then

			attachment0.Parent = humanoidRoot
			attachment0.Axis = Vector3.new(0,0,-1)
			print(humanoidRoot.CFrame.LookVector)
			linearVelocity.Parent = humanoidRoot
			linearVelocity.Attachment0 = attachment0
			linearVelocity.MaxForce = math.huge
			linearVelocity.VelocityConstraintMode = Enum.VelocityConstraintMode.Line
			linearVelocity.LineVelocity = 50
			linearVelocity.RelativeTo = Enum.ActuatorRelativeTo.Attachment0
			linearVelocity.ForceLimitsEnabled = false

		end
	end)
	track:GetMarkerReachedSignal("DashEnd"):Connect(function(paramString)
		print("Termine")
		linearVelocity.LineVelocity = 7
		game:GetService("Debris"):AddItem(attachment0,0.5)
		game:GetService("Debris"):AddItem(linearVelocity,0.5)
	end)
	track:Play()
end

local function backwardDash(player)
	local linearVelocity = Instance.new("LinearVelocity")
	local attachment0 = Instance.new("Attachment")
	local humanoidRoot = player.Character:FindFirstChild("HumanoidRootPart")
	local animator = player.Character:FindFirstChild("Animator") or Instance.new("Animator")
	local hum = player.Character:WaitForChild("Humanoid")
	animator.Parent = player.Character.Humanoid
	dashAnimation.AnimationId = dashAnimations.backward
	local track = animator:LoadAnimation(dashAnimation)
	track:GetMarkerReachedSignal("DashStart"):Connect(function(paramString)
		if humanoidRoot then

			attachment0.Parent = humanoidRoot
			attachment0.Axis = Vector3.new(0,0,1)
			print(humanoidRoot.CFrame.LookVector)
			linearVelocity.Parent = humanoidRoot
			linearVelocity.Attachment0 = attachment0
			linearVelocity.MaxForce = math.huge
			linearVelocity.VelocityConstraintMode = Enum.VelocityConstraintMode.Line
			linearVelocity.LineVelocity = 30
			linearVelocity.RelativeTo = Enum.ActuatorRelativeTo.Attachment0
			linearVelocity.ForceLimitsEnabled = false

		end
	end)
	
	track:GetMarkerReachedSignal("DashEnd"):Connect(function(paramString)
		print("Termine")
		linearVelocity.LineVelocity = 7
		game:GetService("Debris"):AddItem(attachment0,0.5)
		game:GetService("Debris"):AddItem(linearVelocity,0.5)
	end)
	track:Play()
end


local function dash (player : Player, direction : enumDashDirection)
	if direction == enumDashDirection.Forward then
		forwardDash(player)
	elseif direction == enumDashDirection.Backward then
		print("atras")
		backwardDash(player)
	end
end
	

dashEvent.OnServerEvent:Connect(dash)


Sometimes this just happens and the animation events wont work in the published version so you will probably have to wait a while for roblox to process some more

1 Like

Oh didnt know it, thanks I’ll waiting in that case

Yeah its weird I dont know if its just me but it seems to happen all the time

1 Like