Why is my remote event being detected multiple times?
02 | local tool = script.Parent |
03 | local DuplicatePrevention = { } |
04 | local player = tool.Parent.Parent |
05 | script.Parent.Activated:Connect( function (Activated) |
06 | game.ReplicatedStorage.RemoteEvent:FireClient(player) |
09 | game.ReplicatedStorage.ILikeBEaNs.OnServerEvent:Connect( function (plr, target) |
10 | print ( "Client Returned" ) |
12 | if player.Character:FindFirstChild( "Humanoid" ) then |
13 | if player.Character.Humanoid.Health > 0 then |
15 | if target and target.Parent and target.Parent:FindFirstChild( "Humanoid" ) then |
16 | target.Parent.Humanoid.Health = 0 |
This is my code. Everything is working fine, but it prints "Client returned" multiple times. The code is returning 1 the first time. 2 the second time, 3 the third time, 4 the fourth time, so on.
16:35:29.154 Fired Client - Server - Script:7
16:35:29.239 Client Created Value - Client - LocalScript:6
16:35:29.239 Client Fired Event - Client - LocalScript:8
16:35:29.254 Client Returned - Server - Script:10 -- the first time
16:35:29.254 Baseplate - Server - Script:14
16:35:29.255 Client Returned - Server - Script:10 -- this is the second click so it returned again
16:35:29.255 Baseplate - Server - Script:14
Any idea why this happens?