I feel like this question has a relatively simple answer, but I’m not exactly sure how to pass info through remote events. A quick explanation would really be helpful
On the client:
remoteEvent:FireServer(arg1, arg2, arg3, ...)
On the server:
remoteEvent.OnServerEvent:Connect(function(player, arg1, arg2, arg3, ...)
The player
who sent over the RemoteEvent will automatically be passed in as the first argument to the .OnServerEvent
. Depending on what your remote event is for, different information will need to be passed over. For example, a shop, you’d need to know which item the player is trying to buy so you could pass over the item name.
-- Client example 2
remoteEvent:FireServer(itemName)
-- Server example 2
remoteEvent.OnServerEvent:Connect(function(player, itemName)
-- gonna pretend you have this all defined already
if player.Cash.Value >= allItemInfo[itemName].Price then
-- take the cash away
player.Cash.Value -= allItemInfo[itemName].Price
-- give the player the item (however it'd work for your game)
end
end)
2 Likes