Client to other client communication

I was under the impression that bindable events will be fired on all clients in the server, but its only the clients own realm. meaning i cant use bindable events in the client to signal other players.

is there a way that I can signal client to all clients without a server script inbetween?

1 Like

In roblox’s case, no. The server is the only median between clients. Must fire event to server, then back to clients

I tried this right now and it has intense delay. what can i do?

can you send your code? The only delay should be the latency of both clients combined. Everything else should be lightweight.

I have a particle that is emitted from the player, and when around 21 can be in game and emit value can reach 104. I want to allow players to turn off seeing these particles. by stopping client replication.

or am I doing this the worst way possible.

-- Client
local function PlayEffect(Character, ComboShow)
	
	local effect = script.ParticleEmitter:Clone()
	effect.Parent = Character.Torso
	effect:Emit(18 * ComboShow)
	Debris:AddItem(effect, 4)

	local sound = script.Jump:Clone()
	sound.Parent = Character.HumanoidRootPart
	sound.PitchShiftSoundEffect.Octave = 1 + (Combo/200)
	sound:Play()
	Debris:AddItem(sound, .4)
	
	--local sound = script.Dash:Clone()
	--sound.Parent = char.HumanoidRootPart
	--sound:Play()
	--Debris:AddItem(sound, .6)
end

function DoubleJump()
	if humanoid:GetState() == Enum.HumanoidStateType.Freefall or humanoid:GetState() == Enum.HumanoidStateType.Swimming then
		local currentJumpPart = getTouchingJumpPart(char)

		if currentJumpPart and currentJumpPart ~= lastUsedJumpPart then
			lastUsedJumpPart = currentJumpPart
			lastComboTime = time() -- Update the time on a successful jump to reset the timeout

			Combo += .2

			local CollisionHeight = getJumpCollisionHeight(char, humanoid.JumpPower)
			--if CollisionHeight then Combo = 1 end

			humanoid.JumpPower = 50 * Combo
			humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
			
			if Combo ~= 1 then
				game.ReplicatedStorage.Remotes.DJVisual:FireServer(Combo)
			end
		end
	end
	
	UpdateCounter(Combo)
	
	return true
end

game.ReplicatedStorage.Remotes.DJVisual.OnClientEvent:Connect(function(Character, ComboShow)
	PlayEffect(Character, ComboShow)
end)
--server

local DJ = game.ReplicatedStorage.Remotes.DJVisual


DJ.OnServerEvent:Connect(function(Player, Combo)
	DJ:FireAllClients(Player.Character, Combo)
end)

@mc3334

The client is an excerpt but the server is the full script

You have said it yourself. If you wish to stop the emitters by stopping replication, just add an if statement when you receive DJVisual on the client. If FX is enabled, play, otherwise, do nothing.

yeah im doing that right now. BUT doing this replication by signalling twice has big delay, often times the player has already completed the action before the particles and sound are played

Last time I checked direct client → client communication wasn’t possible, however you can do client → server → client communication where the server acts as a middle man relaying information. Something you can do to minimize lag is create prediction systems that given some info try to predict the next state (for example if a ball is flying mid air, given the velocity figure out its likely next location). For the client that starts the communication (the first client) you can also have a different “client view” you show them instead of the “server view” the rest of the clients get. For example if they fire a gun, you can make them listen to the sound instantly, on their client, instead of making them listen to the server-side version of the sound, that the rest of the players will hear.

Also if you plan to send a signal a lot, and having small packet loss/chance of the signal not being received (for example a player requesting to move, ball moving mid air, a gun being fired) you may want to look into UnreliableRemoteEvent

2 Likes

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