Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Should I use Remote Functions or Remote Events for a shop?

Asked by 5 years ago

I really don't want to use remote functions because I heard it slows down everything and I don't know how to operate remote functions for a shop. But I would want to use remote events because its easy to do so which do I use?

1
remote events all the way RayCurse 1518 — 5y

1 answer

Log in to vote
1
Answered by
Rare_tendo 3000 Moderation Voter Community Moderator
5 years ago

Both RemoteEvents and Functions slow down the game if you fire/invoke them too much that it gets over its limit.

When you want to return values, use RemoteFunctions, if you don't want to return anything, use a RemoteEvent.

RemoteFunctions are pretty easy to use and are just like RemoteEvents:

-> Handled in server, invoked on client

-- server script

function RemoteFunction.OnServerInvoke(player)
    print(player.Name)
    return player.Name .. ' invoked the function'
end)

-- local script

print( RemoteFunction:InvokeServer() ) -- <player name here> invoked the function

-> Handled on client, invoked on server


--client function RemoteFunction.OnClientInvoke() return game.Players.LocalPlayer:GetMouse().X end -- server print( RemoteFunction:InvokeClient( some player ) ) -- some player's Mouse's x coordinate on their screen
0
good job User#19524 175 — 5y
0
No. NEVER use :InvokeClient()! Using allows exploiters to break your game because RemoteFunctions yield the script that fired them until they get a response so if the client disconnects before it fires back then the whole script is permanently yielded. Or if the client is a hacker, they can choose not to fire back. If you really want to use them, then you could use a timeout. oreoollie 649 — 5y
Ad

Answer this question