Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is my remote event being detected multiple times?

Asked by 3 years ago
01local explosion = nil
02local tool = script.Parent
03local DuplicatePrevention = {}
04local player = tool.Parent.Parent
05script.Parent.Activated:Connect(function(Activated)
06    game.ReplicatedStorage.RemoteEvent:FireClient(player)
07    print("Fired Client")
08    Activated = nil
09    game.ReplicatedStorage.ILikeBEaNs.OnServerEvent:Connect(function(plr, target)
10        print("Client Returned")
11        if plr == player then
12            if player.Character:FindFirstChild("Humanoid") then
13                if player.Character.Humanoid.Health > 0 then
14                    print(target)
15                    if target and target.Parent and target.Parent:FindFirstChild("Humanoid") then
View all 24 lines...

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?

0
oops forgot the localscript Qwertoony 70 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

use deactivate function when it becomes activated!

0
Thank you for the answer :D I figured it out using a debounce but this also works, I completely for got that. THX :DDD Qwertoony 70 — 3y
Ad

Answer this question