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

Weird error, expected end, got elseif?

Asked by 7 years ago
Edited 7 years ago

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'

0
line 4, you have SetPrimaryCFrame instead of SetPrimaryPartCFrame (referring to your comment on his answer) RobloxianDestory 262 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

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)

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? hermosavida 6 — 7y
Ad

Answer this question