RemoteEvent only being received by 1 player instead of both

I have this RemoteEvent that upon receiving an argument, is meant to send out another separate RemoteEvent that should get picked up by a LocalScript in tools that the player is given (2 tools per player, each with 1 LocalScript that is meant to pick up this RemoteEvent).

Problem is, when testing multiplayer in studio. Sometimes only one tool for each player actually receives the remote,

OR 1 out of 2 tools for ONE of the players is received by the remote,

OR it works and both tools for each player receive the remote (obviously I can’t leave this alone if it works 1/5 or so times)

ServerScript that gets an argument and sends out another RemoteEvent for the tools to pickup:

local crosshair = replicatedStorage:WaitForChild("crosshair")
local crosshair2 = replicatedStorage:WaitForChild("crosshair2")

crosshair.OnServerEvent:Connect(function(player, arg, sentPlayer, ID)		
	local profile = playerData.Profiles[sentPlayer]
	if not profile then return end
	print(arg, sentPlayer, ID)

	if arg == "imageUpdate" then
		profile.Data.Settings.Crosshair = ID
		crosshair2:FireClient(sentPlayer, "updateCrosshair", sentPlayer, ID)
	elseif arg == "imageReset" then
		profile.Data.Settings.Crosshair = ""
		crosshair2:FireAllClients("Default", sentPlayer)
	end
end)

LocalScript in each tool that is meant to receive the RemoteEvent:

local crosshair2 = replicatedStorage:WaitForChild("crosshair2")
local aim = nil

crosshair2.OnClientEvent:Connect(function(arg, sentPlayer, ID)
	if sentPlayer.Name ~= player.Name then return end

	if arg == "Default" then print("default db ".. sentPlayer.Name)
		aim = aimGui:WaitForChild("Aim")
		aimGui:WaitForChild("customCrosshair").Visible = false
		custom = false
	elseif arg == "updateCrosshair" then print("custom db ".. sentPlayer.Name)
		aim = aimGui:WaitForChild("customCrosshair")
		aimGui:WaitForChild("Aim").Visible = false
		aim:WaitForChild("ImageLabel").Image = ID
		custom = true
	end

	if toolEnabled then
		aim.Visible = true
	end
end)

It’s possible you may need a remote function? Instead of a remote event, due to multiple clients having to interact with the server firing at once.
Documentation Here: RemoteFunction | Documentation - Roblox Creator Hub
(not entirely sure but may be worth checking out?)

1 Like