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

Anyone help with this script? [closed]

Asked by 9 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

So I took a copy off of a game and I decided to revamp it. But I can NOT get the random audio working. So, here's the script. I only want the script to play a random audio as soon as zombies/humans win the game. But I can't get it working.

``

p = game.Players:getChildren()
local zombie = math.random(1, #p)
for i = 1, #p do
if (i == zombie) then
p[i].TeamColor = BrickColor.new("Sand green")
else
p[i].TeamColor = BrickColor.new("Bright red")
end
end

m.Text = "If all survivors die, the zombies win!"
wait(1)
for i = 1, #p do
if p[i].Character ~= nil then
    if p[i].TeamColor == BrickColor.new("Bright red") then
        local spawn = math.random(1, #humSpawns)
        p[i].Character.Torso.CFrame = CFrame.new(humSpawns[spawn].Position + Vector3.new(0, 6, 0))
    elseif p[i].TeamColor == BrickColor.new("Sand green") then
        zombify(p[i])
        local spawn = math.random(1, #zombSpawns)
        p[i].Character.Torso.CFrame = CFrame.new(zombSpawns[spawn].Position + Vector3.new(0, 6, 0))
    end
end
end
m.Text = "Choose your weapons and begin!"
game.Workspace.Rawr:play()
game.workspace.Music:play()
wait(3)
m:remove()

script.Running.Value = 1
local time = roundtime  --Time, in seconds.

while script.Running.Value == 1 do
    if math.fmod(time, 60) < 10 then
    scorebar.Text = "Time Remaining:  " .. math.floor(time/50) .. ":0" .. math.fmod(time, 60)
    else
    scorebar.Text = "Time Remaining:  " .. math.floor(time/60) .. ":" .. math.fmod(time, 60)
    end
    wait(1)
    time = time - 1
    if time == 0 then


        print("game ovarrrrrrr")
        script.Running.Value = 0

    end
end

    if script.Running.Value == 0 then
        local z = game.Players:getChildren()
        local humcount = 0
        local zombcount = 0
        for i = 1, #z do
        if z[i].className == "Player" then
            if z[i].TeamColor == BrickColor.new("Bright red") then humcount = humcount + 1
            elseif z[i].TeamColor == BrickColor.new("Sand green") then zombcount = zombcount + 1
            end
        end
        end
        local m = Instance.new("Message")
        m.Parent = game.Workspace
        if humcount >= 1 then
            --[[ local musicids={225032798,225032831,225032853,225032806,225032806} --Change these to the music ids you want to play, feel free to add some music

function PickRandomFrom(tab)

return tab[math.random(1,#tab)]

end

local id=PickRandomFrom(musicids)

local music=Instance.new("Sound",game.Workspace)

music.SoundId=id --I'm not sure if it's called SoundId, probably something else

music:Play() --]]
            game.workspace.Music:stop()
            m.Text = "The Survivors have won!"
            humwins = humwins + 1
        end
        scorebar.Text = "Games Won  |  Survivors: " ..humwins.. "  |  Zombies: " ..zombwins.. "  |"  --Tie: " ..ties
        wait(4)
        m:remove()

    --All Red Team members leave.  It gets turned to this value in a different script.
    elseif script.Running.Value == -1 then
        local m = Instance.new("Message")
        m.Parent = game.Workspace
                        --[[ local musicids={225032722,225032798,225032714,225032744,225032619} --Change these to the music ids you want to play, feel free to add some music

function PickRandomFrom(tab)

return tab[math.random(1,#tab)]

end

local id=PickRandomFrom(musicids)

local music=Instance.new("Sound",game.Workspace)

music.SoundId=id --I'm not sure if it's called SoundId, probably something else

music:Play() --]]
        game.workspace.Music:stop()
        m.Text = "The zombies have taken over the world!"
        zombwins = zombwins + 1
        scorebar.Text = "Games Won  |  Survivors: " ..humwins.. "  |  Zombies: " ..zombwins.. "  |"  --Tie: " ..ties
        wait(4)
        m:remove()

    --All Blue Team members leave.  It gets turned to this value in a different script.
    elseif script.Running.Value == -2 then
        local m = Instance.new("Message")
        m.Parent = game.Workspace
        --[[ local musicids={225032798,225032831,225032853,225032806,225032806} --Change these to the music ids you want to play, feel free to add some music

function PickRandomFrom(tab)

return tab[math.random(1,#tab)]

end

local id=PickRandomFrom(musicids)

local music=Instance.new("Sound",game.Workspace)

music.SoundId=id --I'm not sure if it's called SoundId, probably something else

music:Play() --]]
        game.workspace.Music:stop()
        m.Text = "The Survivors have won!"
        humwins = humwins + 1
        scorebar.Text = "Games Won  |  Survivors: " ..humwins.. "  |  Zombies: " ..zombwins.. "  |"  --Tie: " ..ties
        wait(4)
        m:remove()
    end


    p = game.Players:getChildren()
    wait(5)
    for i = 1, #p do
        if p[i].Character ~= nil then
            p[i].Character.Humanoid.Health = 0
        end
    end
wait(20)

end

``

0
I see what's wrong. YOU'RE TRYING TO MAKE US SCAN AND FIX A 150 LINE SCRIPT! yumtaste 476 — 9y
0
I specially --[['ed the parts I want to fix. God dang it. ShadowsBeans 0 — 9y

Closed as Too Broad by Tortelloni and Unclear

This question has been closed because it is too broad and is generally unanswerable. Please ask a more specific question.

Why was this question closed?