Error: (16,1) Syntax error: Expected 'then' when parsing if statement, got 'end'

So I get the error in the title. I don’t know why? I searched it up and I did it correctly?
This is the script:

UserInputService.InputBegan:Connect(function(inputObject, processed)
	if script.Ragdolled.Changed:Connect(function()
			if script.Ragdolled.Value == true then
				humanoid.BreakJointsOnDeath = false
				humanoid.RequiresNeck=false
				humanoid:ChangeState(Enum.HumanoidStateType.Physics)
				RagdollServerEvent:FireServer(character)
			end
		end)
	end
end)

You have an extra unused end here:
image
And unnecessary if too like @steven4547466 stated.

2 Likes

Try this:

UserInputService.InputBegan:Connect(function(inputObject, processed)
	script.Ragdolled.Changed:Connect(function()
        if script.Ragdolled.Value == true then
            humanoid.BreakJointsOnDeath = false
            humanoid.RequiresNeck=false
            humanoid:ChangeState(Enum.HumanoidStateType.Physics)
            RagdollServerEvent:FireServer(character)
        end
	end)
end)

You have an unnecessary if before your Connect()

4 Likes