Money Bag Drop Script

I want to make a money bag drop that will work by having the player type the amount of money they want to drop in a GUI and then having it subtract that amount from them and making a bag drop on the ground that another player can click to add that amount of money to their own amount of money

the issue is that I don’t know how I would make it so the amount of money the player typed in the GUI would change the amount that the bag gives

i think I have to fire a remote event between the bag of money dropped and the gui, but i was struggling with it

Any help is appreciated

2 Likes

The Number the User has given is Local, the bag is Serverside.
This means that you have to use a RemoteEvent.

You should fire the amount of money that is in the bag using a remote event to a server script. To elaborate, the main idea of remote events is to transfer data from a local script to a server script, mainly because local scripts are limited to accessing the players data whereas you need a server script to change anything on the server such as to move parts around or spawn new parts.

Therefore, you should first use a local script to detect the amount of money that the player types into the GUI (this is because the player’s input into the GUI is a player data). Then, send the money value as a parameter of the remote event to a server script (this is so that you can change anything on the server, in your case being dropping the money bag for all players to see). After the server script receives the remote event, it will create a new unanchored part that represents the money bag with a position right in front of the player - this could be done using CFrame look vector. Following this, add a click detector into your money bag part and detect player click to add it to the player.

2 Likes

thank you so much! this has really helped me a lot

1 Like