Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

IF and ELSE problems, why?

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

✓ Accepted answer

--Expected <eof>, got 'end' Simply means it expected nothing there, , 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)

2 comments

0

Thank you, im relieved that was the only thing wrong. Because i wanted to make it all on my own xD Thank you :)

0

No problem.

This discussion is preserved as it was. New answers, comments, and votes are closed.