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

How to make a main game algorithm?

Asked by 10 years ago

I am making a fairly large game called "Juggernaut", but I have a bug that the "main algorithm", the part that runs when people get teleported to the map and they actually play. They do get teleported to map and get weapons like how I coded it, but the thing is when someone dies nothing happens, and they just spawn in the lobby, and one part works, when they die they do get a boolean variable named "alive" set to false, but the code doesn't react to that. Here's my "main game" code:~~~~~~~~~~~~~~~~~ for y=1, 600 do

wait(1)
Workspace.numberofplayers.Value = 0
for _, v in pairs(game.Players:GetChildren()) do
    repeat wait() until v.Character~=nil and v~=nil
    if v.alive.Value == true then
        Workspace.numberofplayers.Value = Workspace.numberofplayers.Value + 1
    end

end
while game.Players.NumPlayers < 2 or game.Workspace.numberofplayers.Value < 2 do
    b = true
end


if Workspace.numberofplayers.Value == 1 then
    for _,v in pairs(game.Players:GetChildren()) do
        if v~=nil and v.Character~=nil then
            if v.alive.Value == true then
                b = true
                local msg3 = Instance.new("Message", game.Workspace)
                msg3.Text=v.Name .. " has won!"
                wait(5)
                msg3:remove()
                for _, v in pairs(game.Players:GetChildren()) do
                    v.Character:BreakJoints()
                end 
                break
            end
        end
        if b == true then break end
        i = i + 1
    end
    if b == true then break end
end
if b == true then break end

end ~~~~~~~~~~~~~~~~~

1 answer

Log in to vote
1
Answered by
W8X 95
10 years ago

Instead of creating your own variable for the number of players use..

game.Players.NumPlayers

0
I do know that, but I need to make sure that everyone that is in game.Workspace.numberofplayers.Value is alive. fafafefefofo0 0 — 10y
Ad

Answer this question