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

Why does it say expected end to close function at line 5?

****code = "testing" --type your code local gear = game.ReplicatedStorage:WaitForChild('Handgun') Input = script.Parent.Parent.CodeInput Output = script.Parent Output.MouseButton1Down:Connect(function() if Input.Text == code then gear:Clone().Parent = game.Players.LocalPlayer.Backpack gear:Clone().Parent = game.Players.LocalPlayer.StarterGear input.Text = 'Correct' wait (1) input.Text = 'Enter' else input.Text = 'Invalid/Used' wait (1) input.Text = 'Enter' end


thats my script i put and it says expected end to close function at line 5 tried couple times to fix but it ain't gonna fix.

6 comments

0

Please put your code in a code block

0

yea, also organize it, going for organization not space conservation

0

Please use a code block. Also, it means you forgot an end. Add one accordingly.

0

--he tried--

0

I think your missing a “)” as well. Try “end)”.

0

If you're ending a function, then it's "end)", everything else is "end"

1 answer

✓ Accepted answer
code = "testing"
--type your code
local gear = game.ReplicatedStorage:WaitForChild('Handgun')
Input = script.Parent.Parent.CodeInput
Output = script.Parent 
Output.MouseButton1Down:Connect(function() 
	if Input.Text == code then 
		gear:Clone().Parent = game.Players.LocalPlayer.Backpack 
		gear:Clone().Parent = game.Players.LocalPlayer.StarterGear 
		input.Text = 'Correct' 
		wait (1) 
		input.Text = 'Enter' 
	else 
		input.Text = 'Invalid/Used' 
		wait (1)
		input.Text = 'Enter' 
	end
end)

You forgot to add the "end)" at the end of the code block.

1 comment

0

woops i did try end) except my inputs are blue thats why i messed up thanks for the hlep

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