Should I be using RemoteFunction or RemoteEvent with Attributes?

Yesterday, I got this idea where you can use RemoteEvents instead of RemoteFunction, by using Attributes. Roblox said that Attributes are ~18x faster to create dynamically, and I wanted to compare to see if using this method is faster.

I tested it and found out and here are Result

Server
local RemoteFunction = game:GetService("ReplicatedStorage").RemoteFunction
local RemoteEvent = game:GetService("ReplicatedStorage").RemoteEvent

RemoteFunction.OnServerInvoke = function(Player)
	return "Bruh Hello"
end

RemoteEvent.OnServerEvent:Connect(function(Player: Player)
	RemoteEvent:SetAttribute("Test", "Bruh Hello")
end)
Client
local RemoteFunction = game:GetService("ReplicatedStorage").RemoteFunction
local RemoteEvent = game:GetService("ReplicatedStorage").RemoteEvent

local start_time = tick()
print(RemoteFunction:InvokeServer())
print("With remotefunction" ,tick() - start_time)
-----------------------------------------------------------------------------
local start_time = tick()
RemoteEvent:FireServer()
RemoteEvent:GetAttributeChangedSignal("Test"):Wait()
print(RemoteEvent:GetAttribute("Test"))
print("With Attribute", tick() - start_time)

My results are

With RemoteFunction 1.7378270626068115
With Attribute 0.06311607360839844

But I’m wondering is this really a good idea?

I think you’re seeing the side-effects of a lot of startup code affecting the result of your first RemoteFunction test. If you add a task.wait(5) to the top of your LocalScript on the client, you will see that the measured results are nearly identical.

In regard to the “18x faster” statement, that’s in comparison to using Value objects (e.g. StringValue).

4 Likes