These Scripts Don’t Work, I’m trying to make a disaster game but the issue is that these scripts wont work at all, they just error.
Error
12:24:20.318 RBLXDisasters @ 19 Aug 2021 12:24 auto-recovery file was created - Studio - C:/Users/mrtix/OneDrive/Documents/ROBLOX/AutoSaves
12:24:22.281 OnClientEvent can only be used on the client - Server - ShowSurvivorScript:5
12:24:22.282 Stack Begin - Studio
12:24:22.282 Script 'ServerScriptService.ShowSurvivorScript', Line 5 - Studio - ShowSurvivorScript:5
12:24:22.282 Stack End - Studio
12:24:22.282 ServerScriptService.GameLoop:101: Expected ',' when parsing index range, got 'in' - Studio - GameLoop:101
Game Loop
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game.Players:GetPlayers()
local ShowSurvivorEvent = ReplicatedStorage:WaitForChild("Events"):WaitForChild("ShowSurvivorEvent")
local ServerStorage = game:GetService("ServerStorage")
local MapsFolder = ServerStorage:WaitForChild("Maps")
local GameStatisticsGui = game.StarterGui.GameStatisticsGui
local SurvivorList = GameStatisticsGui:WaitForChild("SurvivorsFrame")
local WinReward = 1
local CoinReward = 25
local Status = ReplicatedStorage:WaitForChild("Values"):WaitForChild("Status")
local GameLength = 120
-- Game Loop
while true do
Status.Value = "Waiting For 2 Players..."
repeat wait() until game.Players.NumPlayers >= 1
Status.Value = "Intermission..."
wait(20)
local plrs = {}
for i, player in pairs(game.Players:GetPlayers()) do
if player then
table.insert(plrs,player) -- Adding Players
end
end
wait(2)
local AvaliableMaps = MapsFolder:GetChildren()
local ChosenMap = AvaliableMaps[math.random(1, #AvaliableMaps)]
Status.Value = "Map Chosen!"
local ClonedMap = ChosenMap:Clone()
ClonedMap.Parent = workspace
-- Teleport Map
local SpawnPoints = ClonedMap:FindFirstChild("SpawnPoints")
if not SpawnPoints then
warn("SpawnPoints Can't Be Found! Check if The Grouped Map Has Them!")
end
local AvaliableSpawnPoints = SpawnPoints:GetChildren()
for i, player in pairs(plrs) do
if player then
character = player.Character
if character then
-- Teleport Them
character:FindFirstChild("HumanoidRootPart").CFrame = AvaliableSpawnPoints[1].CFrame
table.remove(AvaliableSpawnPoints,1)
-- Game Tag
local GameTag = Instance.new("BoolValue")
GameTag.Name = "GameTag"
GameTag.Parent = player.Character
else
warn("Player Can't Be Found!")
if not player then
table.remove(plrs,i)
end
end
end
end
wait(2)
Status.Value = "The Game Is Starting!"
for i = GameLength,0,-1 do
for x, player in pairs(plrs) do
if player then
character = player.Character
if not character then
-- Player Left
else
if character:FindFirstChild("GameTag") then
-- Their Alive
else
-- Their Dead
table.remove(plrs,x)
end
end
else
table.remove(plrs,x)
end
end
Status.Value = "Time: "..i
wait(1)
if GameLength == 0 then
for i, player in pairs(#plrs) do
if player then
for i, player in pairs(plrs) do
if player then
for i, GameStatisticsGui in pairs(plrs) do
local GameStatisticsTextLabels = GameStatisticsGui.SurvivorsFrame:GetChildren()
for i = 1 + plrs in pairs(#plrs) do
GameStatisticsTextLabels[i] = plrs.Name
if #plrs == 0 then
Status.Value = "Nobody Won!"
end
end
end
end
end
character = player.Character
if character then
end
end
end
end
Status.Value = "End of game!"
for i, player in pairs(game.Players:GetPlayers()) do
character = player.Character
if not character then
-- Ignore
else
if character:FindFirstChild("GameTag") then
character.GameTag:Destroy()
end
end
player:LoadCharacter()
end
end
ClonedMap:Destroy()
end
Show Survivors Script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ShowSurvivorEvent = ReplicatedStorage:WaitForChild("Events"):WaitForChild("ShowSurvivorEvent")
local StarterGui = game:GetService("StarterGui")
ShowSurvivorEvent.OnClientEvent:Connect(function()
StarterGui:WaitForChild("GameStatisticsGui").SurvivorsFrame.Visible = true
StarterGui:WaitForChild("GameStatisticsGui").TitleLabel.Visible = true
wait(10)
StarterGui:WaitForChild("GameStatisticsGui").SurvivorsFrame.Visible = false
StarterGui:WaitForChild("GameStatisticsGui").TitleLabel.Visible = false
end)