Modulescript function not returning

Local script

local function ToolActivated(Action)
	if not Tool then return end
	
	local AnimationID = ToolAnims:GetAnimationID(Tool.Name, Action)
	animationTrack:GetAnimation("rbxassetid://"..AnimationID, animator)
	local MarkerSignal = animationTrack:PlayAnimation("Dash")
	
	if MarkerSignal then	-- If played animation reaches a certain markersignal
		print(MarkerSignal)
	end
end

Module script

function module:PlayAnimation(MarkerSignal)
	self.animationTrack:Play()
	
	if MarkerSignal then
		self.animationTrack:GetMarkerReachedSignal(MarkerSignal):Connect(function()
			return "Signal Reached"
		end)
	end
end

“Signal Reached” is never printed out. Although I have tried printing out a string within self.animationTrack:GetMarkerReachedSignal(MarkerSignal):Connect(function() and it does work.

You’re connecting a completely different function to GetMarkerReachedSignal. Returning a value from that function will not pass the value back to your original call.

I have no way of testing this (mostly becaue I do not want to create a test animation), but this should work for what you’re trying to do.

function module:PlayAnimation(MarkerSignal)
	self.animationTrack:Play()
	
	if MarkerSignal then
		self.animationTrack:GetMarkerReachedSignal(MarkerSignal):Wait()
		return "Signal Reached"
	end
end