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

I have a error on a script in serverscriptservice that I need help fixing, how would I?

Asked by 3 years ago

I was writing a script for my game and I got an error, I'm not sure how I would fix it, as far as I can tell everything is right. Here's the script.

local MapsFolder = ServerStorage:WaitForChild("Maps")

local Status = ReplicatedStorage:WaitForChild("Status")

local GameLength = 600

local reward = 1

while true do


Status.Value = ("Waiting for enough players")

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

Status.Value = ("Intermission")

wait(38)

local plrs = {}

for i, player in pairs (game.Players:GetPlayers()) do
    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 ("SpawnPoints not found!!! You big dummy!!!")
end

local AvailableSpawnPoints = SpawnPoints:GetChildren()

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

        if character then

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

            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 = "Teleporting"

wait(5.5)

for i = GameLength,0,-1 do

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

            character = player.Character

            if not character then

            else
                if character:FindFirstChild("GameTag") then

                    print(player.Name.." is still alive")
                else

                    table.remove(plrs,x)
                    print(player.Name.." has been killed")
                end 
            end

        else
            table.remove(plrs,x)
            print(player.Name.." has been killed")
        end
    end

    Status.Value = "Time till Deathmatch "..i.." Players remaining "..#plrs..

    if #plrs == 1 then
        Status.Value = plrs[1].Name.." wins!!!"
        plrs[1].leaderstats.Wins.Value = plrs[1].leaderstats.Wins + reward
        break
    elseif  #plrs == 0 then
        Status.Value = "All players have perished "
        break
    elseif i == 0 then
        Status.Value = "Teleporting to Deathmatch "

    end

    wait(1)
end


end

The error is on line 101 with the if, it is underlined and the error says "Expected identifier when parsing expression, got if". Thanks for any help.

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

On line 99 you are trying to concatenate an if statement with a string. You cannot concatenate a string with an if statement. To fix this, simply just remove the .. at the end of line 99.

0
thanks! SheepeySheeps 4 — 3y
0
np! Brandon1881 721 — 3y
Ad

Answer this question