'end' expected near '<eof>' error in my code

how can i fix 'end' expected near '<eof>'? I tried putting end at the last line of the code, also at elseifs, and it still shows this error. (I am really new to lua by the way).

repeat wait() until game.workspace:FindFirstChild("NPC")
wait(2)
if game.PlaceID == 3541987450 then
print("KHEI")
for i, v in pairs(game.Workspace:GetChildren()) do
    if v.Name == "DevilRoom" then
        if v.BrickColor == BrickColor.new("Dark stone grey") and v.Position ~= Vector3.new(-1283.07092, 1164.82434, -2338.98315, 0.0816411376, -0, -0.996661782, 0, 1, -0, 0.996661782, 0, 0.0816411376) then
game.StarterGui:SetCore("SendNotification", {
    Title = "COLLECTOR";
    Text = "HE SPAWNED" .. "\n" .. "[Plains]";
        Duration = 10000;
})

a = Instance.new("Sound")
a.SoundId = "rbxassetid://39518470341"
a.Parent = game.Lighting
a.Volume = 3
a:Play()

elseif v.BrickColor == BrickColor.new("Bronze") and v.Position ~= Vector3.new(-2604.72559, 1097.82373, 1475.93469, 0.995581567, -0, -0.0939007998, 0, 1, -0, 0.0939007998, 0, 0.995581567) then
    game.StarterGui:SetCore("SendNotification", {
        Title = "COLLECTOR";
        Text = "HE SPAWNED" .. "\n" .. "[Jungle]";
        Duration = 10000;
    })
a = Instance.new("Sound")   
a.SoundId = "rbxassetid://3951847031"
a.Parent = game.Lighting
a.Volume = 3
a:Play()
elseif v.BrickColor == BrickColor.new("Fawn brown") and v.Position ~= Vector3.new(-1546.47192, 363.750061, 2445.54663, 0.999748111, 0, 0.0224423129, 0, 1, 0, -0.0224423129, 0, 0.999748111) then
    game.StarterGui:SetCore("SendNotification", {
        Title = "COLLECTOR";
        Text = "HE SPAWNED" .. "\n" .. "[Desert]";
        Duration = 10000;
})
a = Instance.new("Sound")   
a.SoundId = "rbxassetid://3951847031"
a.Parent = game.Lighting
a.Volume = 3
a:Play()

Upvotes: 0

Views: 1177

Answers (1)

dimo414
dimo414

Reputation: 48794

if blocks in Lua are terminated with end. Similarly for loops are terminated with end. You'll need to add them where appropriate in your script; it doesn't look like you're using them at all currently.

The error message mentioning <eof> is a little confusing; it's saying "the parser was looking for an end but it reached the end-of-the-file and never saw one". Not "you need to put an end at the end of the file".

Upvotes: 2

Related Questions