Expected ')' (to close '(' at line 101), got 'end' and Expected identifier when parsing expression, got ')'

I’m getting Expected ‘)’ (to close ‘(’ at line 101), got ‘end’ and Expected identifier when parsing expression, got ‘)’ on this script and I don’t know how to fix it.

userinput.InputEnded:connect(function(object, g)
		if not g then
			if object.UserInputType == Enum.UserInputType.Keyboard then
				local key = object.KeyCode
				if key == Enum.KeyCode.LeftShift then
					if sprinting then
						sprinting = false
						rT:Play()
						player.humanoid.WalkSpeed = 16 * (input.stance == "crouch" and 0.4 or 1)
							end
						end
					end
				end
			end
		end --Expected ')' (to close '(' at line 101), got 'end' 
	end) --Expected identifier when parsing expression, got ')'
end

why do you have so many end

1 Like

Is this part of the Script in a nested function (is this snippet of code in a bigger function)?

userinput.InputEnded:connect(function(object, g)
	if not g then
		if object.UserInputType == Enum.UserInputType.Keyboard then
			local key = object.KeyCode
			if key == Enum.KeyCode.LeftShift then
				if sprinting then
					sprinting = false
					rT:Play()
					player.humanoid.WalkSpeed = 16 * (input.stance == "crouch" and 0.4 or 1)
				end
			end
		end
	end
end)

here try this

do -- input
	input.stance = "stand"
	local sprinting = false
	local default_right = CFrame.new(1, -1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
	local default_left = CFrame.new(-1, -1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
	runservice.RenderStepped:connect(function()
		if animation.crouch then
			if animation.crouch.IsPlaying then
				animation.crouch:AdjustSpeed(Vector3.new(player.torso.Velocity.x, 0, player.torso.Velocity.z).magnitude/10)
			end
		end
	end)
	userinput.TextBoxFocused:connect(function()
		if sprinting then
			sprinting = false
			player.humanoid.WalkSpeed = 16
		end
	end)
	userinput.InputBegan:connect(function(object, g)
		if not g then
			if object.UserInputType == Enum.UserInputType.Keyboard then
				local key = object.KeyCode
				if key == Enum.KeyCode.C then
					if input.stance == "crouch" then
						player.humanoid.HipHeight = 0
						player.humanoid.WalkSpeed = 16
						animation.crouch:Stop(.2)
						input.stance = "stand"
					else
						input.stance = "crouch"
						player.humanoid.HipHeight = -1
						player.humanoid.WalkSpeed = 16 * 0.4
						animation.crouch:Play(.2)
					end
				elseif key == Enum.KeyCode.LeftShift then
					if not sprinting then
						T:Play()
						animation.sprint = player.humanoid:LoadAnimation(script:WaitForChild("sprint"))
						runservice.RenderStepped:connect(function()
							if animation.sprint then
								if animation.sprint.IsPlaying then
									animation.sprint:AdjustSpeed(Vector3.new(player.torso.Velocity.x, 0, player.torso.Velocity.z).magnitude/10)
						sprinting = true
						player.humanoid.WalkSpeed = 16 * (input.stance == "crouch" and 0.8 or 1.5)
					end
				end
			end)
		end
	userinput.InputEnded:connect(function(object, g)
		if not g then
			if object.UserInputType == Enum.UserInputType.Keyboard then
				local key = object.KeyCode
				if key == Enum.KeyCode.LeftShift then
					if sprinting then
						sprinting = false
						rT:Play()
						player.humanoid.WalkSpeed = 16 * (input.stance == "crouch" and 0.4 or 1)
							end
						end
					end
				end
			end
		end
	end)
end

it didn’t work, just had lots of errors

do -- input
	input.stance = "stand"
	local sprinting = false
	local default_right = CFrame.new(1, -1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
	local default_left = CFrame.new(-1, -1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
	runservice.RenderStepped:connect(function()
		if animation.crouch then
			if animation.crouch.IsPlaying then
				animation.crouch:AdjustSpeed(Vector3.new(player.torso.Velocity.x, 0, player.torso.Velocity.z).magnitude/10)
			end
		end
	end)
	userinput.TextBoxFocused:connect(function()
		if sprinting then
			sprinting = false
			player.humanoid.WalkSpeed = 16
		end
	end)
	userinput.InputBegan:connect(function(object, g)
		if not g then
			if object.UserInputType == Enum.UserInputType.Keyboard then
				local key = object.KeyCode
				if key == Enum.KeyCode.C then
					if input.stance == "crouch" then
						player.humanoid.HipHeight = 0
						player.humanoid.WalkSpeed = 16
						animation.crouch:Stop(.2)
						input.stance = "stand"
					else
						input.stance = "crouch"
						player.humanoid.HipHeight = -1
						player.humanoid.WalkSpeed = 16 * 0.4
						animation.crouch:Play(.2)
					end
				elseif key == Enum.KeyCode.LeftShift then
					if not sprinting then
						T:Play()
						animation.sprint = player.humanoid:LoadAnimation(script:WaitForChild("sprint"))
						runservice.RenderStepped:connect(function()
							if animation.sprint then
								if animation.sprint.IsPlaying then
									animation.sprint:AdjustSpeed(Vector3.new(player.torso.Velocity.x, 0, player.torso.Velocity.z).magnitude/10)
									sprinting = true
									player.humanoid.WalkSpeed = 16 * (input.stance == "crouch" and 0.8 or 1.5)
								end
							end
						end)
					end
					userinput.InputEnded:connect(function(object, g)
						if not g then
							if object.UserInputType == Enum.UserInputType.Keyboard then
								local key = object.KeyCode
								if key == Enum.KeyCode.LeftShift then
									if sprinting then
										sprinting = false
										rT:Play()
										player.humanoid.WalkSpeed = 16 * (input.stance == "crouch" and 0.4 or 1)
									end
								end
							end
						end
					end)
				end
			end
		end
	end)
end

Here I add and correct some of the End this should output no error reguarding the identifier now

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.