How do you pass a value from client to server by RemoteEvent?

So the issue that you were having was that you were creating a connection to the .Touched event every time you fired the RemoteEvent, and then not closing the connection. The problem with this is that once you create it, it remains. So after the first time it was created, it was always listening for a collision. My suggestion fixed this by creating a variable that the .Touched event would check, to see if you had actually swung the hammer. The edited script I posted did not handle the scenario where the hit did not connect after swinging. To do that you could wait for the duration of the swing and then set knockback to false.

Another solution to your problem is what @XdJackyboiiXd21 suggested, which is to disconnect the connection to the .Touched event. Both methods should work just fine.

1 Like

This is what I did…

remoteEvent.OnServerEvent:Connect(function(player, command)
	print(command)

	if command then
		knockback = true
		
		wait(.3) --the swing (smashTrack) is .3 long
		knockback = false
	end	
end)

That looks good, did it fix it for you?

1 Like

DUDE!!! THANK YOU SO MUCH! IM CRYING! IVE BEEN CONSTANTLY DOING TRIAL AND ERRORS FOR DAYS NOW! I truly am grateful from the bottom of my heart! ;-;

1 Like