which way is better to get to ReplicatedStorage and why
local RP = game:GetService("ReplicatedStorage") -- 1
local RP = game.ReplicatedStorage -- 2
which way is better to get to ReplicatedStorage and why
local RP = game:GetService("ReplicatedStorage") -- 1
local RP = game.ReplicatedStorage -- 2
I think they’re pretty much the same, but might be better to use GetService to get services like MarketplaceService, TeleportService, TweenService, etc.
Second option will be slightly faster but the difference is negligible.
task.wait(1)
local T1 = os.clock()
local RP1 = game:GetService("ReplicatedStorage")
local T2 = os.clock()
local RP2 = game.ReplicatedStorage
local T3 = os.clock()
print(T2 - T1)
print(T3 - T2)
Developers can change the name of services, while GetService does a class lookup.
(read the replies in the thread I added above, they cover the advantages of GetService perfectly.)
The dot operator is faster. That said- GetService is safer. By grabbing a service directly through that method you are ensured to reach the said service. If it doesn’t exist yet it will be created.
Well, to use the first option, it also looks better xd