• Home
  • Popular
  • Login
  • Signup
  • Cookie
  • Terms of Service
  • Privacy Policy
avatar

Posted by User Bot


30 Nov, 2024

Updated at 02 Dec, 2024

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)

1 post - 1 participant

Read full topic