My goal would be “power” games like blox fruits and other games of this kind.
But I don’t know which one I should use. I’ve been using Roblox Studio for a while and I’ve always done research on the subject, but I’ve never really gotten to the bottom of my question.
My goal is for the player to be able to start the skill and finish it with as little delay as possible and for the server to be able to send it to everyone with less delay.
Currently I’m using RemoteFunction to make skills, but there are delays that RemoteEvent wouldn’t have… I want to know your opinions.
My script base:
Client(Replicator)
local rep = game:GetService("ReplicatedStorage")
local Server = rep.Eventos.Server
local Effects = {}
for _, Module in pairs(script:GetDescendants()) do
if Module:IsA("ModuleScript") then
Effects[Module.Name] = require(Module)
Module:Destroy()
-- ModuleScript with parts, particles and all effects!
end
end
Server.OnClientInvoke = function(Skill, Action, Data)
Effects[Skill][Action](Data)
end
ServerHandler (Damage and perm effects)
local rep = game:GetService("ReplicatedStorage")
local Server = rep.Eventos.Server
local MAXDIST = 300
local Sets = {}
for i, Module in pairs(script:GetDescendants()) do
if Module:IsA("ModuleScript") then
Sets[Module.Name] = require(Module)
end
end
-- The RemoteFunction is called from localscript (input key)
-- Start here and after Replicator with InvokeClient
Server.OnServerInvoke = function(Client, Skill, Action, Data)
local list = game:GetService("Players"):GetPlayers()
for i, player in ipairs(list) do
if player == Client then
table.remove(list, i)
break
end
end
Data.Character = Client.Character
Server:InvokeClient(Client, Skill, Action, Data)
for _, Player in pairs(list) do
local char = Player.Character or Player.CharacterAdded:Wait()
local clientchar = Client.Character or Client.CharacterAdded:Wait()
local croot = clientchar:FindFirstChild("HumanoidRootPart")
local root = char:FindFirstChild("HumanoidRootPart")
if croot and root and (Player.Character.HumanoidRootPart.Position - Client.Character.HumanoidRootPart.Position).Magnitude < MAXDIST then
Server:InvokeClient(Player, Skill, Action, Data)
--Send effects for another players
end
end
Sets[Skill.."Server"][Action](Client, Data)
end
This way, when there are other players around, it ends up generating a longer delay than with just one player (that’s what I feel), I believe that with more players there should be a longer delay, I can’t say because I only have 2 devices to test and no friends.