My remote event fires multiple times

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    i want the event to not fire multiple times

  2. What is the issue? Include screenshots / videos if possible!
    my remote event fires multiple times depending on how many people have the same tool

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    alot ive been trying to fix this for 2 months now

this is a local script for the fire piller tool inside of startergui

uip.InputBegan:Connect(function(input,IsTyping)

	if input.UserInputType == Enum.UserInputType.MouseButton1 and equip == true and playing == false and FPcooldown == false and  Stamina > 20  then 

		if IsTyping then return end
		FPcooldown = true

		playing = true
		exp += 10
		Stamina -= 20
		local mousepos = mouse.Hit.Position

		ExpResize()
		BarResize()

		FirePillerEvent:FireServer(mousepos,plr.level.Value,plr)

		wait(1)
		playing = false

		if playing == false then
			regen()
		end
		wait(2)

		FPcooldown = false
			if input.UserInputType == Enum.UserInputType.MouseButton1 then  return end  
	end

this is a server script inside of server script service where i parent the tools

local function fireconnect(player1)

	givefire = true
	if player1.FireElement.Parent == player1 and givefire == true then 

       print(player1)

		local firebal = game.ServerStorage.FireTools.Fireball:Clone()
		local firepiller = game.ServerStorage.FireTools["Flaming Piller"]:Clone()
		local miniball = game.ServerStorage.FireTools["mini Fireballs"]:Clone()
		local flamingcrash = game.ServerStorage.FireTools["Flaming Crash"]:Clone()

		firebal.Parent = player1.Backpack
		firepiller.Parent = player1.Backpack
		miniball.Parent = player1.Backpack
		flamingcrash.Parent = player1.Backpack

		givefire = false

	end 

end 

and lastly this is the fire piller script inside the tool

event.OnServerEvent:Connect(function(none,mousepos,level,Player)
	
		Player.Character.Humanoid.WalkSpeed = 0
		Player.Character.Humanoid.JumpPower = 0

		local humanoid = Player.Character:WaitForChild("Humanoid")
		local animator = humanoid:FindFirstChild("Animator")

		FinalFirePiller = animator:LoadAnimation(FirePillerAnimation)
		FinalFirePiller:Play()
		wait(0.10)

		local firePiller = realfirepiller:Clone()
		firePiller.Parent = game.Workspace
		firePiller.PointLight.Enabled = true
		firePiller.Position = mousepos
		firePiller.UpwardsFire.Enabled = false
		firePiller.fire.Enabled = true
		firePiller.sparks.Enabled = false
		
		wait(0.50)

		wait(0.20)
		Player.Character.Humanoid.WalkSpeed = 16
		Player.Character.Humanoid.JumpPower = 50

		touched = firePiller.Touched:Connect(function(hit)
			if hit.Parent == Player.Character then return end 

			if hit.Parent:FindFirstChild("Humanoid") then		
				forceEvent:FireAllClients(force.Start(hit.Parent,(hit.Parent.HumanoidRootPart.Position - firePiller.Position).Unit * Vector3.new(0,50,0) + Vector3.new(0,50)))

				ragdollEvent:FireAllClients(ragdoll.Start(hit.Parent))

				hit.Parent.Humanoid:TakeDamage(10 + level) 

				firePiller.CanTouch = false

				wait(2.30)
				ragdoll.Stop(hit.Parent)
			end
		end)

		firePiller.UpwardsFire.Enabled = true
		firePiller.sparks.Enabled = true

		wait(2)
		firePiller.UpwardsFire.Enabled = false
		firePiller.fire.Enabled = false
		firePiller.sparks.Enabled = false

		firePiller.PointLight.Enabled = false
		wait(1)
		
		touched:Disconnect()
		playing = false

end)

i will try any idea at this point

You’re missing something very simple to add: Each FirePillar tool is registering an OnServerEvent listener function that is listening to the FirePillerEvents coming from all of the other fire pillar tools, not just the one it belongs with. Inside the OnServerEvent handler function, you need to check if Player == ToolOwner. Otherwise, every player’s fire pillar tool is going to make a pillar for the firing player, not just his/her copy of the tool!

Also, you should replace:
event.OnServerEvent:Connect(function(none,mousepos,level,Player)
with
event.OnServerEvent:Connect(function(Player,mousepos,level)

And don’t pass the player reference yourself, because that is exploitable. Every server event includes the firing player as the first parameter, and it’s secure because it’s the player who is associated with the network connection. If you pass the player yourself, a player could modify their client or outgoing packets to spoof another player.

omg it worked i cant believe i wasted 2 months just for this to be the answer but thanks so much i never thought this was the problem

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.