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

why does the script say "expected <eof>, got 'end'" whenever i try to close this local function?

I went to clean up some of my scripts and i noticed a weird change in one of my local functions. For some reason my local function did not have an end, so I tried to add one. Instead I got "expected , got 'end'." I don't know why my script could work perfectly while the function could not even close, especially when the function was created outside of the event that it was used for. I just want cleaner scripts halp ;-;)

script that errors

local function GetItemInfo(Asset, Price)
	
	Card.InfoBox.Header.ItemName.Text = Asset.Name
	Card.ReXxInfoBox.Header.ItemName.Text = Asset.Name
	Card.OutletInfoBox.Header.ItemName.Text = Asset.Name
	Card.Creator.Text = Asset.Creator.Name
	Card.Description.Text = Asset.Description 
	
	if Asset.PriceInRobux == nil then
		Card.Price.Text = "Not for sale"
	else
		Card.Price.Text = Price.."R$"
	end			
		
	if Asset.Creator.CreatorType == "Group" then
		local GroupID = Asset.Creator.CreatorTargetId
		Card.ItemImage.Image = game:GetService("GroupService"):GetGroupInfoAsync(GroupID).EmblemUrl
		elseif Asset.Creator.CreatorType == "User" then
			local Name = Asset.Creator.Name
			Card.ItemImage.Image = ("http://www.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&Format=Png&username=%s"):format(Name)
		end
	end		
end

same error script without statements

local function GetItemInfo(Asset, Price)
	
	Card.InfoBox.Header.ItemName.Text = Asset.Name
	Card.ReXxInfoBox.Header.ItemName.Text = Asset.Name
	Card.OutletInfoBox.Header.ItemName.Text = Asset.Name
	Card.Creator.Text = Asset.Creator.Name
	Card.Description.Text = Asset.Description 	
	
end

3 comments

0

Whats the line 21 end for?

0

You have an extra end

0

Yeah, get rid of that end dude

1 answer

✓ Accepted answer

the reason it's telling you you have an extra 'end' is because of this right here, lines 15 - 22:

	if Asset.Creator.CreatorType == "Group" then
		local GroupID = Asset.Creator.CreatorTargetId
		Card.ItemImage.Image = game:GetService("GroupService"):GetGroupInfoAsync(GroupID).EmblemUrl
	elseif Asset.Creator.CreatorType == "User" then
		local Name = Asset.Creator.Name
		Card.ItemImage.Image = ("http://www.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&Format=Png&username=%s"):format(Name)
	end
end
end

i formatted it correctly so you can properly see why you need to remove the extra end.

"if" and "elseif" were a part of each other, and probably because of a misread on your part, you ended up putting an extra end. that's okay, though! just remove it, and things should be fine!

2 comments

0

This helped the issue for me! Thanks!

0

I know about that, that's partially the reason I wrote this question. An if then statement with an elseif never needs 2 ends, it only needs one. For some reason the script wouldn't recognize the elseif statement unless I had two ends. I just took the else if statement out and wrote 2 if then statements instead. Fixed my function. Im just gonna accept your answer anyway, thanks.

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