So i began to create an Arsenal like game and so far so good however i have a problem. I don't know how to give players random guns on spawn. I searched on YouTube for ever and the only thing i found is tool giver by click. If you have time please give me the code. Have a great day/night, God bless you!
Use the math.random
function, which will return a number between two numbers specified.
local random = math.random(1,10) -- will return a random number between 1 and 10
So let's say you have a remote to spawn in and you have a module to equip the gun:
local loadCharacter = ... -- remote local fpsModule = require(...) -- our module local guns = ...:GetChildren() -- get all the guns inside some folder loadCharacter.OnServerEvent:Connect(function(player) player:LoadCharacter() -- load the character aka. spawn local random = math.random(1,#guns) -- get a random number between 1 and the number of guns fpsModule:Equip(guns[random]) -- equip the gun end)
I don't know if you're using modules or sum stuff like that, but I think this can guide you to adapt it to ur framework.
Closed as Not Constructive by Gey4Jesus69
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?