getPropertyReachedSignal firing multiple times?

Get propertyReachedSignal is stacking or something. The iteration goes up by one every time the signal is reached, and I have no clue how to fix it.

-- reloading
userInputService.InputBegan:Connect(function(input, gameProcessed)
	if not gameProcessed and input.KeyCode == keybinds.reload_weapon then
		if 
			viewmodelSettings.equipped and 
			not viewmodelSettings.reloading and 
			gunSettings.ammo < gunSettings.maxAmmo and 
			gunSettings.reserve > 0
		then
			viewmodelSettings.reloading = true
			
			loadedAnimations.hold:Stop()
			loadedAnimations.reload:Play()
			loadedAnimations.reload:AdjustSpeed(gunSettings.reloadSpeed)
			
			loadedAnimations.reload:GetMarkerReachedSignal("magOut"):Connect(function()
				local magClone = weapon.mag:Clone()
				magClone.Parent = game.Workspace
				magClone.CanCollide = true
				magClone.Anchored = false
				
				debris:AddItem(magClone, 2)
				
				print("added!")
				
				weapon.mag.Transparency = 1
			end)
			
			loadedAnimations.reload:GetMarkerReachedSignal("magGrabbed"):Connect(function()
				weapon.mag.Transparency = 0
			end)
			
			loadedAnimations.reload:GetMarkerReachedSignal("magIn"):Connect(function()
				-- play sound effect
			end)
			
			task.wait(loadedAnimations.reload.Length/gunSettings.reloadSpeed)
			
			viewmodelSettings.reloading = false
			
			loadedAnimations.reload:Stop()
			
			if viewmodelSettings.equipped then
				loadedAnimations.hold:Play()
			end
		end
	end
end)

You’re creating a new connection every single time the reload button is pressed. Try changing :Connect(function(), with :Once(function(), which will only fire the section a single time.

Alternatively, you could do loadedAnimations.reload:GetMarkerReachedSignal("magOut"):Wait() to yield until the marker is reached for the first time.

1 Like

Oh man thank you so much. Many thanks man :+1: