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

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

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 ''

1 answer

✓ Accepted answer

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

2 comments

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 ''

0

That's the exact same problem, and therefore the exact same solution. You're missing and 'end'.

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