Event firing twice inside tool?

I have a melee weapon that I’m working on, and so far its working fine, its basically you hold down mouse in order to charge and attack, it is working, until the damage part.
Normally you can deal damage, but I’ve noticed that it deals twice the damage its intended to.
For example a jab damage should do 5 damage, but instead its 10 because the server event was fired twice.
I have no idea why this is happening, this problem seems to only occur when a script is inside the tool, I made a script inside serverscriptservice to receive the event and print “Server control was fired!”
It printed once, but the script inside the tool fired the entire sequence of attacking twice.

I moved said script into the tool, and now it fired twice.

here’s the part from the client that fired the event.

			local RayResult = CastRay(workspace.CurrentCamera.CFrame.Position, (Mouse.Hit.Position - game.Players.LocalPlayer.Character.Head.Position).Unit * Range, game.Players.LocalPlayer.Character:GetChildren())
			if RayResult then
				if RayResult.Instance.Parent:FindFirstChild("Humanoid") then
					Mouse.Icon = ("http://www.roblox.com/asset?id="..Cursors.Hit)
					delay(1, function()
						Mouse.Icon = ("http://www.roblox.com/asset?id="..Cursors.Normal)
					ReplicatedStorage.ServerControl:FireServer(ChargePower, Shoving, ChargingAttack, Blocking, RayResult.Instance.Parent.Humanoid)

and here’s the script that received it.

	warn("Server control was fired!")

I have no idea why this is happening and would like an answer if one is able to provide any.

I also would like to add that, on the client, it seems to only fire the server onceimage


did it fire instantly? or did it wait after 1 sec or smt then it fired again

1 Like

Can you show us how you check for the player’s input?

It fired instantly as soon as the player let go of the left click after charging by holding left mouse down

1 Like
local Mouse = game:GetService("Players").LocalPlayer:GetMouse()
   punch stuff here and fire event
1 Like

Mouse is deprecated though, You should use UserInputService or ContextActionService.

1 Like

Mouse isn’t deprecated but rather that there are better choices. Roblox says Mouse is still supported due to its widely spread use

By saying ‘Mouse is deprecated’ I mean they stopped working on it but I never said they stopped supporting it.

And your point is vaild so, please don’t turn this into a stupid argument.

I’ve never actually used Userinputservice for mouse, am I doing this correctly?

UserInputService.InputBegan:Connect(function(input, gameProcessed)
	if input == Enum.UserInputType.MouseButton1 and not gameProcessed then
       do charging attack thing here

UserInputService.InputEnded:Connect(function(input, gameProcessed)
	if input == Enum.UserInputType.MouseButton1 and not gameProcessed then
       do attack and fire server event here

you forgot to put .UserInputType in input

Alright, it is working now, but uh, the double damage problem still perstists

So you’re trying to say the double damage only appears server-sided but client there is only one?

Exactly, I tried printing stuff on client, and it is only firing the event once, but on the server it do the whole process twice, I’ve tried adding debounce, but that doesn’t work.

I just realized something while taking a bathroom break.
All the players are using the same event, when I was play testing with my friend the damage was multiplied by 4 when there was 4 player, and doing this play test it does the damage 2x because its two player, I think I might try to figure something out.

When you test this, how many players are in the server?

When doing the play test with my friend of 4 player, the damage was multiplied by 4x, and doing play test on roblox studio with 2 player the damage is multiplied by 2x

Can you send us the whole script?

We can’t really see how the bug happens

In which script do you damage the player,local or server

the server did the damage after the client :FireServer

Yeah cool, but can you show us the whole code in the server-side script(s)?