Ello Developers!
As the name says, I've added a round system where every time the round starts, they will be given a random weapon each time they spawn, the problem Is that even If the round starts, the weapons won't be given
Item Giver (Server-Side script located Inside of a folder In workspace, this script gives melees only):
local RS = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local Folder = RS:WaitForChild("Melee")
-- Change the "Folder" if you change the folder name in Replicated Storage
local function onCharacterAdded(character)
local Tools = Folder:GetChildren()
local ToolsTable = Tools
local chosenTools = {}
repeat
local selectedIndex = math.random(1, #ToolsTable)
table.insert(chosenTools, ToolsTable[selectedIndex])
table.remove(ToolsTable, selectedIndex)
until #chosenTools >= 1
-- Numbers of tools going to give
local plr = Players:GetPlayerFromCharacter(character)
for i,v in pairs(chosenTools) do
Folder:FindFirstChild(v.Name):Clone().Parent = plr.Backpack
end
end
local function onAdded(player)
player.CharacterAdded:Connect(onCharacterAdded) -- Triggers when the player spawns or respawns
end
Players.PlayerAdded:Connect(onAdded)
Round Script (ServerScriptServices, Server-side):
local lobbyLocation = game.Workspace.SpawnLocation.Position + Vector3.new(0,3,0)
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local timeEvent = ReplicatedStorage:WaitForChild('TimeEvent')
local function playGame()
local timeAmount = 180
local timerText = 'Remaining Time: '
while timeAmount > 0 do
timeEvent:FireAllClients(timeAmount, timerText)
wait(1)
timeAmount -= 1
end
end
local function playIntermission()
local intermission = 10
local timerText = 'Intermission: '
while intermission > 0 do
timeEvent:FireAllClients(intermission, timerText)
wait(1)
intermission -= 1
end
end
local function resetPlayers()
for _, plr in pairs(game.Players:GetChildren()) do
plr.Character.HumanoidRootPart.CFrame = CFrame.new(lobbyLocation)
local CurrentMapFolder = game.Workspace.CurrentMap:GetChildren()
for _, Map in ipairs(CurrentMapFolder) do
if Map:IsA("Model") then
Map:Destroy()
end
end
local WeaponGiverFolder = game.Workspace.WeaponGivers:GetChildren()
for _, Script in ipairs(WeaponGiverFolder) do
if Script:IsA("Script") then
Script.Enabled = false
end
end
end
end
local function teleportPlayers()
for _, plr in pairs(game.Players:GetChildren()) do
local RandomMap = math.random(1,1)
if RandomMap == 1 then
local OldSFOTHMap = game:GetService("ReplicatedStorage").Maps["Old SFOTH Map"]:Clone()
OldSFOTHMap.Parent = game.Workspace
end
local WeaponGiverFolder = game.Workspace.WeaponGivers:GetChildren()
for _, Script in ipairs(WeaponGiverFolder) do
if Script:IsA("Script") then
Script.Enabled = true
end
end
end
end
while true do
resetPlayers()
playIntermission()
teleportPlayers()
playGame()
end

6 comments
Ello! It appears that It doesn't work, I also found at line 126, that you typed: "roundEvent:Fire("start")". It appears that Its not a valid memeber
roundEvent has to be a bindable event in Replicated storage. That is likely the issue you are running into with my code. If you used a different kind of event for roundEvent, like a RemoteEvent, the code will not work.
One mistake i did notice with my code is that it should be "roundEvent:Fire()" instead of "roundEvent:Fire("start")".
I think It works! Thank you! Oh and also, on the random tool giver part, on line 32, you forgot to put the () After GetChildren
Oh and also, I just realized that, the Item giver won't give you Items anymore when you reset
Weird. I'm not sure why that would be, because it triggers whenever the player's character gets reset.