I have 2 main scripts for a minigame place i am trying so hard to create please help me out:
local minigameList = {
"Statue Sword Fights"
}
local minigameRunning = game.ServerStorage.MinigameRunning
game.ServerStorage.MinigameOver.Event:connect(function(winners,pointsAwarded)
local winnersMessage = "And the winners are:"
for i=1,#winners do
winners[i].leaderstats.Points.Value = winners[i].leaderstats.Points.Value + pointsAwarded
winnersMessage = winnersMessage.." "..winners[i].Name..","
end
winnersMessage = string.sub(winnersMessage, 1, string.len(winnersMessage) - 1).." - Congratulations!"
m = Instance.new("Message",workspace)
m.Text = winnersMessage
wait(10)
m:destroy()
minigameRunning.Value = false
end)
function SelectMiniGame()
return minigameList[math.random(1,#minigameList)]
end
function Start_A_Game()
if #game.Players:GetChildren() > 1 then
minigame = SelectMiniGame()
m = Instance.new("Message",workspace)
m.Text = minigame.." has been chosen! Get ready!!"
wait(10)
m:destroy()
minigameRunning.Value = true
game.ServerStorage[minigame.." StartEvent"]:Fire()
end
end
while true do
wait(1)
if not minigameRunning.Value then
Start_A_Game()
end
end
connections = {}
function GameOver()
for i=1,#connections do
connections[i]:disconnect()
end
connections = {}
game.ServerStorage.MinigameOver:Fire(plrs,50)
end
function SpawnCharacter(plr)
print(map.Name)
repeat wait(1) until plr.Character ~= nil
spawnpoints = map.SpawnPoints:GetChildren()
plr.Character:MoveTo(spawnpoint[math.random(1,#spawnpoints)].Position)
stats = plr.leaderstats
local sword = game.ServerStorage.LinkedSword:clone()
sword.Parent = plr.Backpack
if not stats:findFirstChild("Kills") then
kills = Instance.new("IntValue",stats)
kills.Name = "Kills"
kills.Value = 0
end
end
game.ServerStorage["Statue Sword Fights StartEvent"].Event:connect(function()
plrs = game.Players:GetChildren()
map = game.Workspace["Statue Sword Fights"]
lastSpawnPointUsed = 0
for i,plr in pairs(plrs) do
if plr.Character ~= nil then
lastSpawnPointUsed = lastSpawnPointUsed + 1
SpawnCharacter(plr)
end
connections[#connections + 1] = plr.CharacterAdded:connect(function(chr)
SpawnCharcater(game.Player:GetPlayerFromCharacter(chr))
end)
end
wait(20)
GameOver()
end)
Please help no error popped up in the output window and i cant find the problem so please if you can help please help. |