0

# How does one create a randomizer game? Me and my friend need help.

We are both new to scripting and decided to attempt to create a game which gives a random gun sword and miscellaneous item on each spawn. We have tried pretty much every tutorial we could find and none seem to work if anyone knows how to help us with this I would be very grateful. :)

0
Based off percentage or just plain random? Maximus1027 30 — 5d
0
Plain random PynMan 0 — 5d

0

You could put all the weapons in a dedicated folder in ServerStorage or somewhere and use GetChildren() to get a table with all the weapons. You can use the math.random function to choose a random weapon from the table every time and clone it to the player

local ServerStorage = game:GetService("ServerStorage")
local Players = game:GetService("Players")

-- table with all the weapons
local allWeapons = ServerStorage.Weapons:GetChildren()

-- whenever somebody spawns or respawns, this will run

-- select a random weapon, from 1 (the beginning of the table) to the last value in the table, clone it, and put it in the player's backpack
local randomWeapon = allWeapons[math.random(1, #allWeapons)]:Clone()
randomWeapon.Parent = player.Backpack
end)
end)

0
All right ill try that PynMan 0 — 5d
0
Where do i put the script? I'm assuming ServerScriptService PynMan 0 — 5d
0
Ok it worked tysm been trying for hours lol (for anyone viewing this thread wondering where to but the script just put it in workspace) PynMan 0 — 5d
0
You should put most server scripts in ServerScriptService unless the script is part of a model or something else that's in the world https://developer.roblox.com/en-us/api-reference/class/ServerScriptService OfficerBrah 70 — 5d
0
@PynMan, I recommend you accept @OfficerBrah's answer. This will let people know that this is a verified working answer and it will help increase his reputation on the site KBRM101 413 — 4d