How can I communicate from Client 1 > Server > Client 2? Anything helps!

Information:

I’m trying to re-create an orb system for player deaths. Currently, the system works by checking if the humanoid died then if it died it checks for an object value. If they have the object value then, the orb is cloned to the dead player’s root part. The problem with this is that everyone can see the orbs and I want the system to work only the killer can see the orbs created. Right now, I’m checking if the player has a “Creator Tag” which is just an object value containing the player’s name of who is the killer as a value.

The only way I could think to bypass this is to clone the part to the player’s client. My idea was when you die it fires a remote event to speak to the server. Then, the server communicates to the killer’s client. I was wondering if it’s possible to take in the creator tags value and then go to trigger for that player’s client. I haven’t tried anything because my code is working as of right now. I’m just looking for some information that I can go off of.

I looked on the dev forum but couldn’t find much. All I found was communicating from client > server > same client. Not a different client.

Here is my code from Starter Player Scripts (Local Script):

local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")

local remote = game.ReplicatedStorage.DiedEvent

Humanoid.Died:Connect(function()
	remote:FireServer("playerDied")
end)

Server Script Service (Regular Script):

remote2.OnServerEvent:Connect(function(Player)
	print("Worked1")
	if ("playerDied") then
		print("Worked2")
		local character = Player.Character
		local tag = character.Humanoid:FindFirstChild("creator")
		if tag then
			print("Worked3")
			local debris = game:GetService("Debris")
			local players = game:GetService("Players")

			local despawnTime = 10
			local humanoid = character:WaitForChild("Humanoid")
			local root = character:WaitForChild("HumanoidRootPart")

			local orb = game.ReplicatedStorage.Orb
			local orb1 = orb:Clone()
			local orb2 = orb1.Middle
			debris:AddItem(orb1, despawnTime)
			print("working?")
			orb1.CFrame = root.CFrame
			orb2.CFrame = root.CFrame
			print("working?")
			orb1.Parent = workspace.Orbs
			orb1.Name = tag.Value
			local killer = Instance.new("StringValue")
			killer.Parent = orb1
		end
	end
end)

I just want to figure out how I could communicate back to a different client!

Anything helps. Thanks for reading!

You should use ObjectValues instead.

1 Like

It is an ObjectValue! Sorry! I thought it was a String Value. I’m just using the default creator tags. I’m gonna go change that to ObjectValue.

1 Like

Why does it need to be Client > Server > Client when it could be Server > Clients? You could instead hook the .Died event server-side, (which would already prevent attempts to manipulate that remote in specific in the case of an exploiter, you can never trust the client), and then fire the killer’s client with the character and the orb.

1 Like

Okay, that sounds like a good idea. If I made the .Died function happen on the server how would I fire a specific client and not the client it’s receiving the .died from?

Should I connect it to kill detection instead of .Died? So that it can communicate with the killer?

RemoteEvents have a :FireClient(plr) function, “plr” being the client that’s being fired. You just need to listen to them on the client, just like how you need to listen on the server with the .OnServerEvent event.

OnClientEvent

The OnClientEvent event fires listening functions in LocalScript when either RemoteEvent:FireClient() or RemoteEvent:FireAllClients() is fired by the server from a Script.

This is used to retrieve remote events fired by the server and intended for the client. This event is in place to provide a method for communicating between the server and client, which is well documented in this article. This event retrieves remote events fired by the server to the client.

To fire from the client to the server, you should use RemoteEvent:FireServer() and RemoteEvent.OnServerEvent.

Whichever way you implement it, as long as you have the killer’s player object, and the killed’s character, both accessible to the server, you’ll manage to do it.

1 Like

Great I will try this when I’m home, thank you so much!

1 Like

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