If I want to get another player character by the remote event. Which one is better between:
- send the player instance
-- LOCAL SCRIPT from player want to send their data
local sendFrom = game.ReplicatedStorage.EventSendFrom
sendFrom:FireServer()
-- SERVER SCRIPT that receives the data then send to another player
local Players = game:GetService("Players")
local sendFrom = game.ReplicatedStorage.EventSendFrom
local sendTo = game.ReplicatedStorage.EventSendTo
sendFrom.OnServerEvent:Connect(function(player)
for i, otherPlayer in pairs(Players:GetChildren()) do
if player ~= otherPlayer then
sendTo:FireClient(otherPlayer, player)
end
end
end)
-- LOCAL SCRIPT from player who receive the data
local sendTo = game.ReplicatedStorage.EventSendTo
sendTo.OnClientEvent:Connect(function(fromPlayer)
-- Get player character that send from
local fromPlayerCharacter = fromPlayer.Character
end)
- send the player name
-- LOCAL SCRIPT from player want to send their data
local sendFrom = game.ReplicatedStorage.EventSendFrom
sendFrom:FireServer()
-- SERVER SCRIPT that receives the data then send to another player
local Players = game:GetService("Players")
local sendFrom = game.ReplicatedStorage.EventSendFrom
local sendTo = game.ReplicatedStorage.EventSendTo
sendFrom.OnServerEvent:Connect(function(player)
for i, otherPlayer in pairs(Players:GetChildren()) do
if player ~= otherPlayer then
sendTo:FireClient(otherPlayer, player.Name)
end
end
end)
-- LOCAL SCRIPT from player who receive the data
local sendTo = game.ReplicatedStorage.EventSendTo
sendTo.OnClientEvent:Connect(function(fromPlayerName)
-- Get player character that send from
local fromPlayerCharacter = workspace:FindFirstChild(fromPlayerName)
end)
Can anyone explain to me, which way is better? and why? Since this might improve the network performance of the game. Thanks in advance!
Ps.
I’m currently developing a game right now, it’s easy-to-play fighting game and have level-up system. If you guys are interested in being a tester or any contributor, please see my game page: Internet PVP - Roblox . After that join my group and contact me via social media site. I planned to release a very pre-alpha of it at the end of February 2022 for tester only.