How To Give Player A New Weapon When They Get A Kill

Hello. Im Making A FPS Game and I want the player to get a new random weapon everytime they get a killed with their current one.
I made many scripts but non of them work. :frowning:
Can Someone teach me how to make one?

1 Like

Here’s how I’d do it:

  1. Make a table with all the guns (Dictionary is recommended in this case, okay if you place it in a module script)
  2. Make an event that happens every time a player kills someone (You can do this using bindable events, BindableEvent | Roblox Creator Documentation)
  3. Get a random gun from the table
  4. (Optional) If you don’t want the player to have the same gun twice, remove the gun from the table (You can search up on how to do this if you don’t know)
1 Like

Sorry, I am kind of a noob in roblox studio. How do I make a table with all the guns?

Here’s 2 examples:
Normal table (aka an array):

local array = {"Gun1", "Gun2", "Gun3"}

Dictionary requires keys, like

local dictionary = {
   ["Gun1"] = --Insert gun here,
   ["Gun2"] = --Insert gun2 here,
   --etc.
}

Note that tables with more than 1 item need a , after every item except the last

I might go off, sorry if I don’t reply

Alright! Thank you for your time!

1 Like