Attributes Vs RemoteEvents

I’m currently trying to replicate a few values from server to client and I don’t know what I should use.
Are attributes faster and better for performance or are RemoteEvents better?

3 Likes

Attributes replicate but they can’t handle every data type (such as tables). I prefer to use remotes. You could either use RemoteEvent’s or RemoteFunctions to transfer data from server to client or client to server

2 Likes

Oh sorry I didn’t say I wanted to send data to client…

2 Likes

I know you and like I said you can use RemoteEvents or RemoteFunctions to transfer data from the server to the client (and vise versa)
to transfer data to the client all you have to do is use a method

RemoteEvents

--Server
local Remote = Instance.new("RemoteEvent",workspace)
Remote:FireClient(game:GetService("Players").LittleBilly, true, "Hello LittleBilly")
Remote:FireAllClients(false, "Hello everyone")


--Client
local Remote = workspace:FindFirstChildWhichIsA("RemoteEvent")
Remote.OnClientEvent:Connect(IsSpecific : boolean, msg : string)
    if IsSpecific then
        print("The server sent you something specific:", msg)
    else
        print("The server sent you something:", msg)
    end
end)

RemoteFunctions

--Server
local Remote = Instance.new("RemoteFunction",workspace)
Remote:FireClient(game:GetService("Players").LittleBilly, "Hello LittleBilly")


--Client
local Remote = workspace:FindFirstChildWhichIsA("RemoteFunction")
function Remote.OnClientInvoke(msg : string)
      print("The server Invoked you something:", msg)
      return "LittleBilly got the message"
end
1 Like

Performance wise, they are close enough to where using one over the other simply for that extra optimization isn’t worth it. If you use them efficiently then it really shouldn’t matter. Attributes should not be used as a substitution for RemoteEvents though, they have very different use cases. Attributes are replicated to the client, yes, but they are limited in the type of values they can store. They should be used for cases such as stats for a weapon (damage, firerate, reload time), vehicle (speed, color) or just anything that does not need to be retrieved from the server using a RemoteEvent or RemoteFunction.

2 Likes

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