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

hello im trying to make a noobs vs zombies game and my restart script is not working?

Asked by 4 years ago
Edited by DeceptiveCaster 4 years ago
for index, child in pairs (game.Workspace:getChildren()) do
if child:isA("Model") then
if child:FindFirstChild("Zombie") or child:FindFirstChild("Humanoid") then -- kills all
child:BreakJoints()
end
end
end

for index, child in pairs (game.Workspace:getChildren()) do
if child:isA("Part") or child:isA("Message") then
child:remove()
end
end

for index, child in pairs (game.Workspace:getChildren()) do
if child:isA("Model") and not child:FindFirstChild("Zombie") and not child:FindFirstChild("Humanoid") then -- removes map
child:remove()
end
end

wait(0.2)
function KillAll() -- the kill all function
    local players = game.Players:GetChildren()
    for i=1,#players do
        if players[i].Character ~= nil then 
            players[i].Character.Humanoid.Health = 0
            end
            end
        end

local lobby = Instance.new("Team")
lobby.Name = "Lobby" -- create team
lobby.Parent = game.Teams
lobby.TeamColor = BrickColor.new("White")

local lmap = game.Lighting.Lobby:Clone()
lmap.Parent = game.Workspace

for index, child in pairs (game.Players:getChildren()) do
child.TeamColor = BrickColor.new("White")
end

for index, child in pairs (game.Players:GetChildren()) do
if child:FindFirstChild("rig") then
child.rig:remove()
else
end
end

game.Teams.Zombies.AutoAssignable = false
game.Teams.Noobs.AutoAssignable = false
local Msg = Instance.new("Message")
Msg.Parent = game.Workspace
Msg.Text = "The game has ended and now will restart. Please wait."
wait(20)
Msg.Text = "Choosing map....."
if choice == 1 then
for index, child in pairs (game.Lighting.Maps.Winter:getChildren()) do
if child:isA("Part") or child:isA("SpawnLocation") then
local parts = child:Clone()
parts.Parent = game.Workspace
end
end
wait(5)
for index, child in pairs (game.Lighting.Maps.Winter:getChildren()) do
if child:isA("Model") then -- do not mess with all this stuff
local model = child:Clone()
model.Parent = game.Workspace
model:MakeJoints()
end
end
Msg.Text = "Map chosen"
wait(1.2)
Msg.Text = "The map Chosen is Winter, made by Cadentopia and edited by SelectLOL12345"
wait(5)
Msg.Text = "Game ready!"
wait(1.5)
Msg.Text = "Choose your team."
wait(2.5)
target = CFrame.new(-231.193, 199.62, -1210.084)
for i, player in ipairs(game.Players:GetChildren()) do
player.Character.Torso.CFrame = target + Vector3.new(0, i * 5, 0)
end
Msg:remove()
wait(20)
game.Teams.Zombies.AutoAssignable = true
game.Teams.Noobs.AutoAssignable = true -- MAKE SURE YOU ADD NOOBS AND ZOMBIES TEAM OR BREAK
KillAll()
lobby:remove()
lmap:remove()
local music = math.random(1,2)
if music == 1 then
game.Workspace.Music.Music:stop()
wait(0.5)
game.Workspace.Music.Music.Pitch = 1
game.Workspace.Music.Music.SoundId = "http://www.roblox.com/asset/?id=150755805"
wait(0.5)
game.Workspace.Music.Music:play()
wait(0.6)
elseif music == 2 then
    game.Workspace.Music.Music:stop()
wait(0.5)
game.Workspace.Music.Music.Pitch = 1
game.Workspace.Music.Music.SoundId = "http://www.roblox.com/asset/?id=162588318"
wait(0.5)
game.Workspace.Music.Music:play()
wait(0.6)
    end
script.Disabled = true
0
Use the lua code blocks.. Torren_Mr 334 — 4y
0
Code has been put in a block. DeceptiveCaster 3761 — 4y
0
block??? jablesgamer1 2 — 4y
0
whats a lua code block ;-; im new to codeing jablesgamer1 2 — 4y
0
can i have help makeing it work? jablesgamer1 2 — 4y

Answer this question