Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make my GUI gun shop actually distribute the weapon?

Asked by 4 years ago

I was wondering how other people have done this with FE. I have the other aspects of the gun shop set up and they all work accordingly, but when it comes to actually give the player the gun I am at a loss. I have tried multiple methods and I still can not find something that actually wants to work. This is what I have:

script.Parent.MouseButton1Click:connect(function()
    local player = script.Parent.Parent.Parent.Parent.Parent
    local Mon = player.leaderstats.Cash.Value
    if Mon >= 900 then
        local update = Mon - 900
        local Event = game.ReplicatedStorage.MoneyUpdate
        Event:FireServer(update)






    end
end)

After it fires the server to change the money and save the datastore, I do not know how to get the gun from server storage (Or possibly somewhere else if needed?) and into the player's backpack. I am having this issue because I can not get a server script to insert it into the backpack and I can not get a local script to do it either because then it just does not work.

0
Guessing by the player variable your probably using a server script. Switch to local cause that the only way you can fire the Remote event. If ur unsure about your FE skills here's a good video explaining it:https://www.youtube.com/watch?v=vpPVNDXvfy8&list=PL9XdvFXu9ApD4Kt_StK1AgApdK9u6uRM-&index=4. Finally If you want to get a tool into the players backpack. clone it client side and parent it ser Bl_ueHistory 94 — 4y
0
@Bl-ueHistory: You can fire a RemoteEvent from the server or client. chess123mate 5873 — 4y
0
No, it is a local script. I just copied it from an old server script and decided not to change that variable because it still works. JazzyUnder 18 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

Some tips:

  • Don't tell the server how much money the player should have left - tell the server what the player wants to buy (otherwise a hacker can just send in a request to give themselves tons of money). You will have to come up with a way of communicating which gun the player wants to buy -- ex, you could assign a unique number or string for each gun, or just pass a reference to the gun model the player wants to buy.
  • The server should then verify that the player has sufficient money and only then clone the gun from ServerStorage and place it in the player's backpack. Since this will occur on the server, the gun will be replicated to the client.
1
Thanks, this is exactly what I was looking for. I am aware about the hacker thing, I just haven't got around to making the server do it. I didn't think about assigning each weapon/tool an id number and it worked really well. JazzyUnder 18 — 4y
Ad

Answer this question