I am a beginner and would like to create a trading function that is common in simulator games. However, I don’t quite understand the structure of sharing or exchanging data with other players. Could you tell me how to share data with a simple player?
example:
When player1 presses the textbutton, a message is sent to player2
When player1 presses the textbutton, the specified amount of coins (leaderstats.coin) is awarded to player2.
Here’s some simple code think of it this way there are 2 players Player 1 and Player 2, you put a TextButton and a script:
script.Parent.MouseButton1Up:Connect(function(plr) --basically it activates when the button is pressed
Local Playerwanted = game.workspace.Player2--gets the other player
Playerwanted.leaderstats.coins.Value += 50
end
end)
For the first one, you would need to use remote events to communicate from the local players UI to the server, which would give information regarding items/coins ect. The server would then communication with the player2 from there. If you don’t know how to use remote events there is plenty of youtube tutorials
That would be one way to do it, however, if you’re looking for security, this is the most vulnerable. However, it’s up to the developer to choose which way they want to handle currency!