Inventory UI is broken, any ideas what I did wrong?

First of all, here is the script.

game.ReplicatedStorage.Events.ItemAdded.OnClientEvent:Connect(function(Itemname)
	local Template = game.ReplicatedStorage.UIStorage.Template:Clone()
	Template.Name = Itemname
	Template.Text = Itemname
	Template.Parent = script.Parent
	Template.Visible = true
	
	Template.MouseButton1Click:Connect(function()
		Template.DropItem.Visible = true
		Template.ItemCancel.Visible = true
		
	Template.DropItem.MouseButton1Click:Connect(function()
		game.ReplicatedStorage.Events.ItemRemove:FireServer(Template.Text)
		Template:Destroy()
	end)
end)

Basically I’m trying to make an inventory system for one of my upcoming games, however, when I click the “template” UI Button its supposed to show up 2 extra buttons, and when you click “cancel,” the two buttons should disappear. However, if you click “drop,” the button should go away, and the item should drop on the ground. However, I’m getting this error, any ideas why? Im still pretty new to scripting, so my scripts might not even make sense at all. Sorry!

Error:

 20:12:45.736  Players.PoweredPilots.PlayerGui.BackPack.InventoryUI.Main:21: Expected 'end' (to close 'function' at line 1), got <eof>; did you forget to close 'function' at line 16?  -  Studio - Main:21

Add another end, as you have three events but only two ends.

Like this.

game.ReplicatedStorage.Events.ItemAdded.OnClientEvent:Connect(function(Itemname)
	local Template = game.ReplicatedStorage.UIStorage.Template:Clone()
	Template.Name = Itemname
	Template.Text = Itemname
	Template.Parent = script.Parent
	Template.Visible = true
	
	Template.MouseButton1Click:Connect(function()
		Template.DropItem.Visible = true
		Template.ItemCancel.Visible = true
     end)
		
	Template.DropItem.MouseButton1Click:Connect(function()
		game.ReplicatedStorage.Events.ItemRemove:FireServer(Template.Text)
		Template:Destroy()
	end)
end)
1 Like

I added end) in the wrong spot, thanks man!

1 Like