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

Getting unexpected symbol error?

Asked by
WindNT 16
7 years ago

Hi! I cannot figure out what is wrong with this script. I am getting error:

Workspace.Door.Script:23: unexpected symbol near ')'

Any help will be appreciated!

Original Code:

local tp = Vector3.new(game.Workspace.TPINSIDE.Position)

script.Parent.Touched:connect(function(plr)
    local name = plr.Name
    local plrPart = game.Workspace:FindFirstChild(name)
    local dataFind = plr:FindFistChild("enter")

    if dataFind == nil then
        local data = Instance.new("IntValue")
        data.Parent = plr
        data.Name = "enter"
        data.Value = 1
        plrPart.HumanoidRootPart.CFrame = CFrame.new(tp)
    else if dataFind.Value == 0 then
        dataFind.Value = 1
        plrPart.HumanoidRootPart.CFrame = CFrame.new(tp)
    else if dataFind.Value == 1 then
        -- show message
    else
        print("Not a player")
    end

end)

Cheers! WindNT

1 answer

Log in to vote
0
Answered by
RubenKan 3615 Moderation Voter Administrator Community Moderator
7 years ago
Edited 7 years ago

The problem lays in your if statement. You use else if instead of elseif, wich would mean it requires an end for every new if.

What you're basicly doing is:

script.Parent.Touched:connect(function(plr)

    if dataFind == nil then
        -- stuff
    else 
        if dataFind.Value == 0 then
            -- stuff
        else 
            if dataFind.Value == 1 then
                -- stuff
            else
                -- stuff
            end
        end)

--see the problem here? Not enough ends.

The easy way to solve this:

You gotta change your else if into elseif, because it'd require a few extra ends otherwise. That's all.

0
OH! Thank you so much! I totally did not notice that. XD WindNT 16 — 7y
0
No problem. Have fun :D RubenKan 3615 — 7y
Ad

Answer this question