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

Weird error, expected end, got elseif?

I'm writing a script and I can't seem to make this error go away at elseif.

event.OnServerEvent:connect(function()
	if sp2.Opened.Value == false then
		for _,v in pairs(sp:GetChildren()) do
			sp:SetPrimaryCFrame(sp:GetPrimaryPartCFrame() * CFrame.new(Settings.Speed * Settings.Direction,0,0))
			sp.Opened.Value = true
			game:GetService('RunService').Stepped:wait()
	elseif sp2.Opened == true then -- 
		for _,v in pairs(sp:GetPrimaryPartCFrame() * CFrame.new(Settings.Speed * Settings.Direction,0,0))
		sp.Opened.Value = false
		game:GetService('RunService').Stepped:wait()
		end
	end
end)

In the output logs:

19:39:15.641 - Workspace.Door.clicky.InteractionDistribution:50: 'end' expected (to close 'for' at line 46) near 'elseif'

1 comment

0

line 4, you have SetPrimaryCFrame instead of SetPrimaryPartCFrame (referring to your comment on his answer)

1 answer

✓ Accepted answer

The answer is simple. You're missing an end to close off the for loop at line 03. Here's a fixed version of your code:

event.OnServerEvent:connect(function()
    if sp2.Opened.Value == false then
        for _,v in pairs(sp:GetChildren()) do
            sp:SetPrimaryCFrame(sp:GetPrimaryPartCFrame() * CFrame.new(Settings.Speed * Settings.Direction,0,0))
            sp.Opened.Value = true
            game:GetService('RunService').Stepped:wait()
	end
    elseif sp2.Opened == true then -- 
        for _,v in pairs(sp:GetPrimaryPartCFrame() * CFrame.new(Settings.Speed * Settings.Direction,0,0))
        sp.Opened.Value = false
        game:GetService('RunService').Stepped:wait()
        end
    end
end)

1 comment

0

Thanks! That got rid the current error. After the revision, it's giving me a new error, "SetPrimaryCFrame is not a valid member of Model" How does a simple change like that result in this?

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