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

What does 'end' expected (to close 'if' at line 12) near '<eof>' mean?

Asked by 8 years ago

I'm a newbie to lua right now and I looked at the error and I never knew what that error meant but I do know what other errors mean.

local dialog = script.Parent dialog.DialogChoiceSelected:connect(function(player, choice) -- Check the player has a stats object local stats = player:FindFirstChild('leaderstats') if not stats then return end

local KOs = stats:FindFirstChild('KOs')
if not KOs then return end

if choice == dialog.DialogChoice['YES'] then
    if KOs.Value >= 1500 then
        game.ReplicatedStorage.Weapon6:Clone().Parent = player.Backpack
        KOs.Value = KOs.Value - 1500

Now here's the output

Workspace.Dilinz Fifto.Head.Dialog.Script:15: 'end' expected (to close 'if' at line 12) near '<eof>'

1 answer

Log in to vote
1
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
8 years ago
Edited 8 years ago

You always have to have an end when working with functions, if statements, most loops, etc. You have it on line 2.

The end tells the script where the if statement, well, ends. It's where the code will stop being effected by the outcome of the condition and just run normally. It's pretty straightforward.

if choice == dialog.DialogChoice['YES'] then
    if KOs.Value >= 1500 then
        game.ReplicatedStorage.Weapon6:Clone().Parent = player.Backpack
        KOs.Value = KOs.Value - 1500
    end
end
0
I have another problem. 14:33:36.884 - Workspace.Dilinz Fifto.Head.Dialog.Script:17: 'end' expected (to close 'function' at line 2) near '<eof>' robertwoodsy5115 16 — 8y
0
That's the exact same problem, and therefore the exact same solution. You're missing and 'end'. Perci1 4988 — 8y
Ad

Answer this question