Problem communicating with module script

Hello! After reworking my ability system to include modules, I have a problem to fix:

--Server Script
rs.Remotes.SkillDown.OnServerEvent:Connect(function(plr, ability, magic, holding)
	holding = true
	Magic[magic][ability](plr, holding)
end)
rs.Remotes.SkillUp.OnServerEvent:Connect(function(plr, ability, magic, holding)
	holding = false
end)
--Module Script
return function(plr, isHoldingDown)
  while isHoldingDown == true do wait()
	  if charge <= 100 then
		 charge = charge + 1
	   	 iterator = iterator + 0.1
		 circle.Size = circle.Size + Vector3.new(0,0.05,0.05)
	  end
	  if charge == 100 then
         break
	  end
   end
end

My problem is that I can’t communicate to the module script whenever isHoldingDown turns false, so therefore the charge always maxes out to 100, not taking into account whether I release the key before the charge reaches 100 or not.

How can I fix this?

I would declare the holding variable at the top of the module script then have another function that changes holding to false in the module script that you can call.

1 Like

Thank you! Somebody told me that I shouldn’t be storing stuff(except for my main function) inside my module script so I completely missed that solution.

Works perfectly now!