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

IF and ELSE problems, why?

Asked by 8 years ago

So im trying to make a button which opens a door, then you click it again and it closes it. Im not great at scripting but this is my attempt. (NOTE: the door works shutting and closing with a ontouch script.) The problem is that it keeps saying that error at the bottom. Ive tried lots of ends and it still says it.

Explorer of bricks and scripts: Here

b = true
a = script.Parent.Parent.Part
function onClicked(playerWhoClicked)
    if b == true then
        script.Sound:Stop()
        a.CFrame = a.CFrame + Vector3.new(0, 0.5, 0)
        script.Sound:Play()
        wait(0.1)
        for i=1, 17 do
            a.CFrame = a.CFrame + Vector3.new(0, 0.5, 0)
            wait(0.1)
        b = false
        end
    else
        wait(0.1)
        wait(4)
        script.Sound:Play()
        for i=1 ,18 do
            a.CFrame = a.CFrame + Vector3.new(0, -0.5, 0)
            wait(0.1)
        end
        wait(3)
        b = true
    end
    end
end --Expected <eof>, got 'end'
script.Parent.ClickDetector.MouseClick:connect(onClicked)

1 answer

Log in to vote
3
Answered by 8 years ago

--Expected <eof>, got 'end' Simply means it expected nothing there, <eof>, but got end. All you have to do is remove the end.

b = true
a = script.Parent.Parent.Part
function onClicked(playerWhoClicked)
    if b == true then
        script.Sound:Stop()
        a.CFrame = a.CFrame + Vector3.new(0, 0.5, 0)
        script.Sound:Play()
        wait(0.1)
        for i=1, 17 do
            a.CFrame = a.CFrame + Vector3.new(0, 0.5, 0)
            wait(0.1)
        b = false
        end
    else
        wait(0.1)
        wait(4)
        script.Sound:Play()
        for i=1 ,18 do
            a.CFrame = a.CFrame + Vector3.new(0, -0.5, 0)
            wait(0.1)
        end
        wait(3)
        b = true
end; end
script.Parent.ClickDetector.MouseClick:connect(onClicked)

0
Thank you, im relieved that was the only thing wrong. Because i wanted to make it all on my own xD Thank you :) LittleBigDeveloper 245 — 8y
0
No problem. SimplyRekt 413 — 8y
Ad

Answer this question