Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Round Not Working?

Asked by 8 years ago

This is a simple script that makes rounds. Unfortunately, when the Alien dies, nothing happens. The if statement is supposed to make all the players beside the alien get points when this happens, but it never does. Script Analysis gives me no errors, nor the output!


local localtimer = roundtime while localtimer > 0 do wait(1) localtimer = localtimer - 1 message.Value = "Round Time Left: (" .. localtimer .. ")" activeplayers = {} -- local player = players[math.random(1, #players)] for _, player in pairs(game.Players:GetPlayers()) do local humanoid = player.Character:WaitForChild("Humanoid") if humanoid and humanoid.Health > 0 then table.insert(players, player) for _, players in pairs(activeplayers) do if player then if player.Character then if player.Character.Humanoid.Health > 0 then if player.Character:FindFirstChild("activetag") then table.insert(activeplayers, player) end end end end end end end alienactive = true --local player = players[math.random(1, #players)] local playersin = {} for _, player in pairs(game.Players:GetPlayers()) do local humanoid = player.Character:WaitForChild("Humanoid") if humanoid and humanoid.Health > 0 then table.insert(playersin, player) end end if alien.Character.Humanoid.Health > 0 then alienactive = true local function remove_value(Table, Value) for i,v in pairs (Table) do if v==Value then table.remove(Table,i) end end end remove_value(playersin, alien) if localtimer == 0 then message.Value = "Time's Up! It's a Draw!" break end print(#playersin) if #playersin == 0 then message.Value = "The Alien Has Won!" alien.leaderstats.Wins.Value = alien.leaderstats.Wins.Value + 1 alien.leaderstats.Points.Value = alien.leaderstats.Points.Value + 300 break end if alien.Character.Humanoid.Health == 0 then alienactive = false message.Value = "The Alien Has Lost!" print ("ALL IS LOST!!!") for _, player in pairs(#playersin) do local humanoid = player.Character:WaitForChild("Humanoid") if humanoid and humanoid.Health > 0 then player.leaderstats.Points.Value = player.leaderstats.Points.Value + 200 player.leaderstats.Wins.Value = player.leaderstats.Wins.Value + 1 end end break end end end -- KILL JDNhuebvhjfkvet7 for _, player in pairs(game.Players:GetPlayers()) do local humanoid = player.Character:WaitForChild("Humanoid") if humanoid and humanoid.Health > 0 then table.insert(players, player) player.Character.Humanoid.Health = 0 end end wait (5) script.Parent.Disabled = false script.Disabled = true
0
First of all, you should keep the game in a while true do wait() loop, instead of disabling it then enabling it. passtimed 45 — 8y
0
I fixed it. Turns out, putting comments in is useful. :/ fight4moneyalt2 27 — 8y

Answer this question