I don’t know if this would actually be more efficient and I don’t think I have a way to test it effectively.
I’m creating a combat system and while it does math and calculates hits on the server, all of the VFX and other details are done on client to reduce lag as I want to be able to run upwards of 50 players servers.
I’m using :FireAllClients() and :FireClient() to communicate between the two, as these will be sent to all players, the server is doing what I believe to be a lot.
Is it possible to simply use a StringValue, json tables, and value.ValueChanged:Connect() in order to fulfill the same job which FireAllClients() does? The only information being transferred is the player name and move name.
I want to know if this is out of wack or there’s some issue with this I’m not seeing.
FireAllClients is the best option in this case, objects like StringValue I would use it as storage, and as in this case there is no information to store, I don’t see the need to change it.
FireAllClients is optimized for this task. You might find ways to limit how many players receive each event to save network traffic, for example if they are out of range or in a different regeion. Don’t worry about such an optimization until when / if you actually hit a performance issue.
Totally possible, but that’s the same thing that FireAllClients does. You’re transferring data over the network either way, except that FireAllClients is built and optimized for the task.
I’m using this to handle my status effects, many of which cause specific particles, 3d particle effects, and sounds to play on a character. This is where I’d want to actually use this if I was going to, as it’d use the same amount of listeners on client, however instead of fire a function its changing a value. In a large lobby of players, this would be firing :FireAllClients() multiple times per second. I know changing single properties is incredibly efficient as demonstrated by stuff like PartCache.
Server performance is very important with this as similar games tend to run into issues with high player counts and high move usage.
PlayerStatusArray = {{PlayerName, tick()+cooldowntimer, StatusName}}
local function CheckAllStatus()
for i,v in pairs(PlayerStatusArray) do
if v[2] <= tick() then
ReplicatedStorage.Remotes.VFXRemote:FireAllClients(Live[v[1]], v[3])
end
end
end
task.spawn(function()
while true do
wait(.1)
pcall(CheckAllStatus)
end
end)