First,
This is not a request site. its a site where you try to figure it out first then ask for help if you cant get it
A push in the right direction
TO do this youll need some basic math and checking if the player has it.
Getting down to the actual code
For buying things its simple, just use the event you want and use simple math to subtract that from the money. But we need to check it first!
3 | script.Parent.Touched:connect( function (hit) |
4 | if hit:FindFirstChild( "Humanoid" ) then |
Pretty self explanatory. but how do we take money out if their value? Simple subtraction!
3 | script.Parent.Touched:connect( function (hit) |
4 | if hit:FindFirstChild( "Humanoid" ) then |
5 | If money.Value > = cost then |
6 | money.Value = money.Value - cost |
See? Simple! But what about putting it in with them? easy again, we need to adjust our code and add on to your other map/ spawning script
04 | script.Parent.Touched:connect( function (hit) |
05 | if hit:FindFirstChild( "Humanoid" ) then |
06 | local plr = game.Players:GetPlayerFromCharacter(hit.Parent) |
07 | If money.Value > = cost then |
08 | money.Value = money.Value - cost |
09 | TOOL:Clone().Parent = plr |
17 | for i, plr in pairs (game.PLayers:GetPlayers()) do |
19 | if plr:FindFirstChild( "TOOL" ) then |
20 | plr.TOOL:Clone().Parent = plr.BackPack |
And thats all! :D Hope i helped! If i did thumb up my answer and accept it!
if you do not know how to code do not ask for people to make it for you on this site
Closed as Not Constructive by evaera
This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.
Why was this question closed?