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

I made some code in starterplayerscripts and I came into a error with "end)"?

The code basically deletes and constructs code when I press tab.

--if _ Keydown delete and create new Gui
game:GetService("UserInputService").InputBegan:connect(function(key)
if key.KeyCode == Enum.KeyCode.Tab then
	print 'the key Tab has been pressed'
	local Gui = game.Players.LocalPlayer.PlayerGui:FindFirstChild("One")
	if Gui then Gui:Destroy() 
	end
------------------------------------------------------------------------------------
	player = game.Players.LocalPlayer
	gui = game.Lighting.Two
	
	gui:Clone().Parent = player.PlayerGui
	local Gui = game.Players.LocalPlayer.PlayerGui:FindFirstChild("Two")
	if Gui then Gui:Destroy()end 
	
	
------------------------------------------------------------------------------------
	


end
end)  --ERROR HERE

1 answer

✓ Accepted answer

You didn't enclose your functions properly. This is generally shown when an the final enclosure to a big function is highlighted red.


--if _ Keydown delete and create new Gui
game:GetService("UserInputService").InputBegan:connect(function(key)
**if key.KeyCode == Enum.KeyCode.Tab then**
    print 'the key Tab has been pressed'
    local Gui = game.Players.LocalPlayer.PlayerGui:FindFirstChild("One")
    if Gui then 
	Gui:Destroy() 
    end
end --You ended the function above, but not the one highlighted in bold.
------------------------------------------------------------------------------------
    player = game.Players.LocalPlayer
    gui = game.Lighting.Two

    gui:Clone().Parent = player.PlayerGui
    local Gui = game.Players.LocalPlayer.PlayerGui:FindFirstChild("Two")
    if Gui then 
	Gui:Destroy()
    end 


------------------------------------------------------------------------------------



end
end)  --ERROR HERE


P.S - Work on your syntax, it'll help us debuggers out a ton. Happy scripting.

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