Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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 comment

1

remote events all the way

1 answer

✓ Accepted answer

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

2 comments

0

good job

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.