Script
local status = game:GetService("ReplicatedStorage"):WaitForChild("Status")
local serverstorage = game:GetService("ServerStorage")
local inround = game.ReplicatedStorage:WaitForChild("InRound")
local intermissionlength = 10
local increment = 1
local goal = 0
local roundlength = 120
local highest
local teams = game:GetService("Teams")
local playing = teams:WaitForChild("Playing")
local lobby = teams:WaitForChild("Lobby")
local playerservice = game.Players
local obj
local deathmatch = false
local slippery
local won = false
local eventlength = 30
function resetround()
roundlength = 120
end
function resetintermission()
intermissionlength = 10
end
function resetevent()
eventlength = 30
end
function awardcoins(plr, input)
print(plr.Name)
print(plr.ClassName)
plr:WaitForChild("leaderstats"):WaitForChild("Coins").Value += input
end
function awardlevels(plr, input)
plr:WaitForChild("Levels"):WaitForChild("Exp").Value += input
end
local clone
local clone1
inround.Changed:Connect(function()
print("yay it chhanged")
if inround.Value == true and #playerservice:GetChildren() > 1 then
for i,v in pairs(playerservice:GetChildren()) do
local char = v.Character or v:LoadCharacter()
if v.Team == "Playing" then
print("erm what the sigma im looking at u like what the ligma")
else
print("errr")
char.HumanoidRootPart.CFrame = workspace.Goal.CFrame
v.Team = playing
end
end
while true do
task.wait(1)
print("okaaa 52")
if #playerservice:GetChildren() <= 1 then
deathmatch = false
print("okaaa 55")
status.Value = "Not enough players to start the game!"
break
end
if inround.Value == false then
print("okaaa 60")
break
end
eventlength -=1
if deathmatch == true then
print("okaaa 65")
status.Value = "Death match ends in: ".. roundlength .. " seconds"
else
print("okaaa 68")
status.Value = "Next event in: ".. eventlength .. " seconds"
if eventlength == goal then
if clone ~= nil then
print("okaaa 72")
clone:Destroy()
end
if clone1 ~= nil then
print("okaaa 76")
clone1:Destroy()
end
local random = math.random(1,2)
if random == 1 then
local lowgrav = coroutine.create(function()
for i,v in pairs(game.Players:GetChildren()) do
local char = v.Character or v.CharacterAdded:Wait()
print("okaaa 84")
if v == nil then
else
char:WaitForChild("Humanoid").JumpPower = 75
end
task.wait(eventlength)
if v == nil then
else
char:WaitForChild("Humanoid").JumpPower = 50
end
end
end)
coroutine.resume(lowgrav)
status.Value = "Low gravity"
elseif random == 2 then
slippery = coroutine.create(function()
print("okaaa 100")
workspace.Hill.CustomPhysicalProperties.FrictionWeight = 100
task.wait(eventlength)
workspace.Hill.CustomPhysicalProperties.FrictionWeight = 50
end)
coroutine.resume(slippery)
status.Value = "The hill is now reaaallllyyy slippery"
end
resetevent()
end
end
roundlength -= increment
if roundlength == 0 then
local HighestVal, HighestPlayer
print("okaaa 114")
for _, player in game.Players:GetPlayers() do
if not HighestVal or player.Character.Tag.Value > HighestVal then
HighestVal = player.Character.Tag.Value
HighestPlayer = player
end
end
status.Value = "The winner is " .. HighestPlayer.Name .." with a time of " ..math.round(HighestVal).. " seconds!"
print("okaaa 123")
print("The winner is" .. HighestPlayer.Name .." with " ..math.round(HighestVal).. " time!")
awardcoins(game:GetService("Players"):FindFirstChild(HighestPlayer.Name), 150)
print("okaaa 126")
deathmatch = false
inround.Value = false
task.wait(3)
resetevent()
resetround()
print("okaaa 132")
end
if roundlength == goal then
print("okaa 136a")
if clone ~= nil then
print("okaaa 138")
clone:Destroy()
end
if clone1 ~= nil then
print("okaaa 142")
clone1:Destroy()
end
print("okaaa 145" )
inround.Value = false
resetround()
break
end
end
elseif inround.Value == false and #playerservice:GetChildren() > 1 then
print("okaaa LINE 152")
for i,v in pairs(playerservice:GetChildren()) do
print("okaaa LINE 154")
print(v.Team)
if v.Team == playing then
local char = v:LoadCharacter() or v.Character
print("Playing!!!?" .. char.Name)
print("don't do anythin gpls")
elseif v.Team == lobby then
local char = v:LoadCharacter() or v.Character
print("lobby?" .. char.Name)
print("okay LINE 163")
print(char.Name)
print(char.HumanoidRootPart.Position)
char:WaitForChild("HumanoidRootPart").CFrame = workspace.Spectator.CFrame
print(char.HumanoidRootPart.Position)
v.Team = lobby
end
end
while true do
if #playerservice:GetChildren() <= 1 then
print("okaaa LINE 208 174")
status.Value = "Not enough players to start the game!"
resetintermission()
resetround()
resetevent()
break
end
task.wait(1)
print("okaaa LINE 182")
status.Value = "Intermission: ".. intermissionlength .. " seconds"
intermissionlength -= increment
if intermissionlength == goal then
inround.Value = true
print("okaaa LINE 187")
intermissionlength = 10
break
end
end
end
end)
game.Players.PlayerAdded:Connect(function()
if #playerservice:GetChildren() <= 1 then
print("okaaa LINE 196")
status.Value = "Not enough players to start the game!"
resetintermission()
resetround()
resetevent()
else
print("okaaa LINE 202")
inround.Value = false
end
end)
game.Players.PlayerRemoving:Connect(function()
if #playerservice:GetChildren() <= 1 then
print("okaaa LINE 208")
resetintermission()
resetround()
status.Value = "Not enough players to start the game!"
end
end)
Yeah I’ve made 4 posts within 2 days of problems with this script, and I encountered another problem.
But I realized I think I need to just tidy this script up completely as it’s an absolute mess, the way I wrote is horrible and if somebody could tell me how I could not make it such a mess it’d be much apperciated