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

End of a if statement coming up with an error How to fix it?

--------------------------------------------------------------------------------------
--------------------[ GAMEPAD CONTROLS ]---------------------------------------------------
--------------------------------------------------------------------------------------
local userInputService = game:GetService("UserInputService")
userInputService.InputChanged:connect(function(input, processed)
	if input.UserInputType == Enum.UserInputType.Gamepad1 then
		if input.KeyCode == Enum.KeyCode.ButtonX then
			Reloading = true
		if input.UserInputType == Enum.UserInputType.Gamepad1 then
		if input.KeyCode == Enum.KeyCode.ButtonB then
			Knifing = true
		end
		if input.UserInputType == Enum.UserInputType.Gamepad1 then
		if input.KeyCode == Enum.KeyCode.ButtonL1 then
			ThrowingGrenade = true
		end
		if input.UserInputType == Enum.UserInputType.Gamepad1 then
		if input.KeyCode == Enum.KeyCode.ButtonL2 then
			Aiming = true
		end
		if input.UserInputType == Enum.UserInputType.Gamepad1 then
		if input.KeyCode == Enum.KeyCode.ButtonY then
			if Stance == 0 then
			Stance = 1
			end
			if input.UserInputType == Enum.UserInputType.Gamepad1 then
		if input.KeyCode == Enum.KeyCode.ButtonY then
			if Stance == 1 then 
				Stance = 3
				end

4 comments

3

Tip: Tab your code properly and place ends in the proper places.

0

... where are these "Proper Places"?

0

you need to have an end for every if statement...

0

... and for every function your creat I.e. "connect(function() end)" or "function Test() end" etc.

1 answer

✓ Accepted answer

I decided to clean up your code, making all syntax correct. This does NOT mean the following code will work, as your question was only about the end's.

--------------------------------------------------------------------------------------
--------------------[ GAMEPAD CONTROLS ]---------------------------------------------------
--------------------------------------------------------------------------------------
local userInputService = game:GetService("UserInputService")
userInputService.InputChanged:connect(function(input, processed)
	if input.UserInputType == Enum.UserInputType.Gamepad1 then
		if input.KeyCode == Enum.KeyCode.ButtonX then
			Reloading = true
		elseif input.KeyCode == Enum.KeyCode.ButtonB then
			Knifing = true
		elseif input.KeyCode == Enum.KeyCode.ButtonL1 then
			ThrowingGrenade = true
		elseif input.KeyCode == Enum.KeyCode.ButtonL2 then
			Aiming = true
		elseif input.KeyCode == Enum.KeyCode.ButtonY then
			if Stance == 0 then
				Stance = 1
			elseif Stance ==1 then
				Stance = 3
			end
		end
	end
end)

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