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

i am getting some errors in my script, and was wondering if you could help me get them out?

Asked by 4 years ago

ocal Replicatedstorage = game:GetService("ReplicatedStorage")

local Serverstorage = game:GetService("ServerStorage")

local MapsFolder = Serverstorage:WaitForChild("Maps")

local Status = Replicatedstorage:WaitForChild("Status")

local Gamelength = 60 local reward = 15

while true do

Status.Value = "waiting for enough players"

repeat wait(1) until game. Players.NumPlayers >= 2

Status.Value = "intermission"

wait(10)

local plrs = {}

for i, player in pairs (game.players:GetPlayers() ) do

end
if player then 
    table.insert(plrs,player)
end

end wait(2)

local AvailableMaps = MapsFolder:GetChildren()


local ChosenMap = AvailableMaps[math.random(1,#AvailableMaps)]

Status.Value = ChosenMap.name.. "chosen"
local ClonedMap = ChosenMap:Clone()
ClonedMap.Parent = workspace

local SpawnPoints = ClonedMap:FindFirstChild("SpawnPoints")

if not SpawnPoints then
    print("You dont have SpawnPoints!")
end
local AvailableSpawnPoints = SpawnPoints:GetChildren()
for i, player in pairs(plrs) do
    if player then
        character = player.character

        if character then
            character:FindFirstChild("HumanoidRootPart").CFrame = AvailableSpawnPoints[1].CFrame
            table.remove(AvailableSpawnPoints,1)

            local Sword = ServerStorage.Sword:Clone()
            Sword.Parent = player.Backpack
            local GameTag = Instance.new("BoolValue") 
            GameTag.name = "GameTag"
            GameTag.Parent = player.character

            else

            if not player then
                table.remove(plrs,i)
            end

        end
    end
end 

 Status.Value = "Get ready to Play!"
 wait(2)

 for i = Gamelength, 0,-1 do 
for x, player in pairs(plrs)  do
    if player then
        character = player.charecter
        if not character then

        else
            if character:FindFirstChild("GameTag") then
                print(player.name.."is still in the Game!")
            else
                    table.remove(plrs,x)
                    print(player.name.."has been removed!")
            end
        end
    else
            table.remove(plrs,x)
            print(player.name.."has been removed!"
    end
end


Status.Value = "There are "..i.."seconds remaining, and"..#plrs.."players left"
if #plrs == 1 then
    Staus.Value = "The winner is"..plrs[1].name
    plrs[1].leaderstats.Cash.Value = plrs[1].leaderstats.Cash.Value + reward
    break 
elseif #plrs == 0 then
        Status.value = "Nobody won!"
        break
elseif i == 0
        then
            Status.Value = "times up!"
            break
end
wait(1)

end print("End of game!") for i,player in pairs:Getplayers() do

character = player.character
if not character then
else
    if character:FindFirstChild("GameTag") then
        character.GameTag:Destroy()
    end
    if player.Backpack:FindFirstChild("Sword") then
        player.Backpack.Sword:Destroy()

    end
    if character:FindFirstChild("Sword") then
        character.Sword:Destroy()
    end


end
player:Loadcharacter()

end

ClonedMap:destroy() Status.Value = "Game ended" wait(2)

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local ServerStorage = game:GetService("ServerStorage")

local MapsFolder = ServerStorage:WaitForChild("Maps")

local Status = ReplicatedStorage:WaitForChild("Status")

local GameLength = 120

local reward = 1

-- Game Loop
while true do
Status.Value = "Waiting for more Players..."
repeat wait(1) until game.Players.NumPlayers > 1

for i = 15, 0, -1 do
        local fulltext = "("..i..")" -- change to the text you want
        local text = ""

        for i = 1,#fulltext do
         text = fulltext:sub(1,i)
        Status.Value = text
         wait()
        end
    wait(0.95)
    end


local plrs = {}

for i, player in pairs(game.Players:GetPlayers()) do
    if player then
        table.insert(plrs, player) -- Add each player into players table
    end
end

wait(1)

local AvailableMaps = MapsFolder:GetChildren()

local ChosenMap = AvailableMaps[math.random(1,#AvailableMaps)]

local fulltext = ChosenMap.Name.."" -- change to the text you want
local text = ""

for i = 1,#fulltext do
 text = fulltext:sub(1,i)
 Status.Value = text
 wait()
end

wait(5)

for i = 10, 0, -1 do
        local fulltext = "Players will be teleported in ("..i..")" -- change to the text you want
        local text = ""

        for i = 1,#fulltext do
         text = fulltext:sub(1,i)
        Status.Value = text
         wait()
        end
    wait(0.4)
    end

local ClonedMap = ChosenMap:Clone()
ClonedMap.Parent = workspace



wait(1)

--Teleport players to the map

local SpawnPoints = ClonedMap:FindFirstChild("SpawnPoints")

if not SpawnPoints then
    print("Spawn points not found!")        
end

local AvailableSpawnPoints = SpawnPoints:GetChildren()

for i, player in pairs(plrs) do
    if player then
        character = player.character
        if character then

    character:FindFirstChild("HumanoidRootPart").CFrame = AvailableSpawnPoints[1].CFrame + Vector3.new(0,10,0)
    table.remove(AvailableSpawnPoints,1)

    local Sword = ServerStorage.Sword:Clone()
    Sword.Parent = player.Backpack

    local GameTag = Instance.new("BoolValue")
    GameTag.Name = "GameTag"
    GameTag.Parent = player.Character
    else
     if not player then
                    table.remove(plrs,i)
                    end
               end
    end

end

if ClonedMap:FindFirstChild("SpawnPoints") then
    ClonedMap.SpawnPoints:Destroy()
end

local fulltext = "Get Ready to Play!" -- change to the text you want
local text = ""

for i = 1,#fulltext do
 text = fulltext:sub(1,i)
 Status.Value = text
 wait()
end


wait(1)

for i = GameLength,0,-1 do

    for x, player in pairs(plrs) do
        if player then

            character = player.Character

            if not character then
                -- Left the game
                table.remove(plrs,x)
            else
                if character:FindFirstChild("GameTag") then
                    -- They are still alive
                    print(player.Name.." is still in the game!")
                else
                    -- They are dead
                    table.remove(plrs,x)
                    print(player.Name.." has been removed!")
                end
            end
        else
            table.remove(plrs,x)
            print(player.Name.." has been removed!")
        end
    end

local fulltext = ""..i.." seconds remaining" -- change to the text you want
local text = ""

for i = 1,#fulltext do
 text = fulltext:sub(1,i)
 Status.Value = text
 wait()
end

    if #plrs == 1 then
        -- Last person standing"The winner is "..plrs[1].Name
        local fulltext = "The winner is "..plrs[1].Name -- change to the text you want
        local text = ""

        for i = 1,#fulltext do
        text = fulltext:sub(1,i)
        Status.Value = text
        wait()
        end
        plrs[1].leaderstats.Wins.Value = plrs[1].leaderstats.Wins.Value + reward
        wait(5)
        break
    elseif #plrs == 0 then
         local fulltext = "Nobody won!" -- change to the text you want
        local text = ""

        for i = 1,#fulltext do
        text = fulltext:sub(1,i)
        Status.Value = text
        wait()
        end
        wait(3)
        break
    elseif i == 0 then
         local fulltext = "Times up!" -- change to the text you want
        local text = ""

        for i = 1,#fulltext do
        text = fulltext:sub(1,i)
        Status.Value = text
        wait()
        end
        wait(3)
        break
    end


    wait(1)
end

print("End of game")

for i, player in pairs(game.Players:GetPlayers()) do
    character = player.Character

    if not character then
        -- Ignore them
    else
        if character:FindFirstChild("GameTag") then
            character.GameTag:Destroy()

        if player.Backpack:FindFirstChild("Sword") then
            player.Backpack.Sword:Destroy()
        end

        if character:FindFirstChild("Sword") then
            character.Sword:Destroy()
end
end

ClonedMap:Destroy()

player:LoadCharacter()

local fulltext = "Game Ended" -- change to the text you want
        local text = ""

        for i = 1,#fulltext do
        text = fulltext:sub(1,i)
        Status.Value = text
        wait()
        end
end
end
end

Upvote if this was helpful :)

0
The script does not do anything, It does not teleport or any thing BIGJIM20 -6 — 4y
0
It might not be the script then.. Nistrict 44 — 4y
0
It might not be the script then.. Nistrict 44 — 4y
Ad

Answer this question